I have a JSON snippet that looks like this:
{"123":{"name":"test","info":"abc"}}
123 is an identifier and may change with every request. This is uncontrollable.
I want to deserialize JSON using JSON.NET. I tried:
User u = JsonConvert.DeserializeObject<User>(json);
However, this does not work if I do not define the JsonProperty attribute JsonProperty this:
[JsonProperty("123")] public string ID { get; set; }
But, of course, I canβt do this, because ID 123 will change with every request.
How can I read the ID property using JSON.NET and apply it to the ID class?
source share