I\'m playing a little bit with the new StackOverflow API. Unfortunately, my JSON is a bit weak, so I need some help.
I\'m trying to deserialize this JSON of a User:<
As Alexandre Jasmin said in the comments of your question, the resulting JSON has a wrapper around the actual User object you're trying to deserialize.
A work-around would be having said wrapper class:
public class UserResults
{
public User user { get; set; }
}
Then the deserialization will work:
using (var sr = new StringReader(json))
using (var jr = new JsonTextReader(sr))
{
var js = new JsonSerializer();
var u = js.Deserialize(jr);
Console.WriteLine(u.user.display_name);
}
There will be future metadata properties on this wrapper, e.g. response timestamp, so it's not a bad idea to use it!