Number to bool converter for Json.NET
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
LICENSE
README.md
appveyor.yml

README.md

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 :)