Skip to content

Latest commit

 

History

History
62 lines (49 loc) · 1.4 KB

README.md

File metadata and controls

62 lines (49 loc) · 1.4 KB

BooleanConverter

Build status NuGet License

Integer to Boolean converter for Json.NET

Installation

Install-Package BooleanConverter

Usage

namespace UsageExample
{
    public class ApiData
    {
        [JsonConverter(typeof(BooleanConverter))]
        public bool Field { get; set; }
    }

    public class ConverterTest
    {
        [Fact]
        public void SerializeHappyPath()
        {
            //Arrange
            var apiJson = "{ Field : 1}";

            //Act
            var result = JsonConvert.DeserializeObject<ApiData>(apiJson);

            //Assert
            Assert.Equal(true, result.Field);
        }
    }
}

Build

Install .NET Core SDK

Open src folder in the command prompt. Then

    dotnet restore
    dotnet build

Tests

Open src\JsonNetConvertersTest folder in the command prompt. Then

    dotnet test

.NET Standart compatibility

Library was created with supporting for .NET Standart 1.3

Contributing

Don't be shy to ask a question or offer something :)