Soraya Sánchez
Soraya Sánchez

Reputation: 31

I'm having trouble deserializing a Boolean data

I present my case:

I have a JSON file with X information with this field (which is what I'm having trouble with)

{
.........
  "isUrgent": true,
.........
}

In VS Professional with c# and .net Core I have the following code

using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json;

public class RegisterObject
{
.........
[JsonProperty("isUrgent", Required = Required.Always)]
        public bool IsUrgent { get; set; }
..........
}

Through postman, I send my JSON to the VS Proffesional solution.

{
.........
  "isUrgent": 100,
.........
}

I send a JSON that contains any numeric (we are testing) and the system converts it to Boolean, specifically to the value true, giving the system as valid.

I hope you can help me :) Thanks and regards.

Upvotes: 2

Views: 73

Answers (1)

Soraya Sánchez
Soraya Sánchez

Reputation: 31

As Denis said:

You can follow this issue on github It's the thing you are looking into.

It's a library problem. Thank you for the help :)

Upvotes: 1

Related Questions