0

I have a simple JSON object which look like the following in sunny day scenario:

{
  "JsonProp1": "4ADx4ADx",
  "JsonProp2": "4AH/4ADx",
  "JsonProp3": "4AKq4ADx"
}

I have also implemented a class for that.

internal class JsonData
{
    public JsonData(byte[] jsonProp1 , byte[] jsonProp2 , byte[] jsonProp3) 
        {
            JsonProp1 = jsonProp1;
            JsonProp2 = jsonProp2;
            JsonProp3 = jsonProp3; 
        }
        public byte[] JsonProp1 { get; set; }

        public byte[] JsonProp2 { get; set; }

        public byte[] JsonProp3 { get; set; }
}

My question would be the following: what would be the input parameter for the deserializer to retrive null?

JsonData? jsonData= JsonSerializer.Deserialize<JsonData>(InputJson);

In case the input is wrong (e.q. not json format) it throws an exception. If the input is correct syntactically but not compatible it return with JsonData but properties are null.

THE_GREAT_MARKER
  • 476
  • 4
  • 13

0 Answers0