Deserializing JSON into an object with Json.NET

If you don’t want to create a wrapper class you can also access the User this way:

String jsonString = "{\"user\":{\"user_id\": 1, \"user_type\": \"moderat...";
JToken root = JObject.Parse(jsonString);
JToken user = root["user"];
User deserializedUser = JsonConvert.DeserializeObject<User>(user.ToString());

See this page in the Json.NET doc for details.

Leave a Comment