0

I need to directly deserialise "systemversion" property to System.Version. Below is the code sample.

string  myJsonResponse = "{"systemversion":{"Major":1,"Minor":0,"Build":0,"Revision":0}}";
      
var jObject = JObject.Parse(myJsonResponse);
          
var version = jObject["systemversion"].ToObject<System.Version>();     

Issue raised : Cannot deserialize the current JSON object (e.g. 
    {"name":"value"}) into type 'System.Version' because the type requires a JSON string value to deserialize correctly.
    To fix this error either change the JSON to a JSON string value or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
   Path 'Major', line 1, position 129.

Can some one help me to directly deserialise the "systemversion" property to System.Version ?

kush
  • 77
  • 6
  • Annoyingly, use of `VersionConverter` is now the default. You'll have to find out how to remove it – canton7 Jul 27 '23 at 12:12

0 Answers0