I am trying to pars json string:
{"name":,"age":30,"car":null}
First problem occurs when I parse json string into token.
JToken token = JToken.Parse(json);
After pasing json string json token has additional curly bracers.
{{"name":,"age":30,"car":null}}
Could you tell me why?
Next problem occurs when I try yo deserialize json string into .net object.
JToken.Parse() adds undefined to the name property:
{{"name": undefined,"age":30,"car":null}}
And deserialization fails. I expect that it will add null to the name property so json string can be converted to the .net object without exception. But, it doesn't and I am getting exception:
Newtonsoft.Json.JsonReaderException: 'Unexpected character encountered while parsing value: u. Path 'name', line 2, position 11.'
How can I successfully parse such json string so it could be safely converted to the .net object?
Here is class structure for json string:
public class User
{
public string name { get; set; }
public int age { get; set; }
public object car { get; set; }
}