JObject.Parse vs JsonConvert.DeserializeObject

Priya
Priya
Member
62 Points
26 Posts

Hi,

I am working around json parsing. There is two techniques available to parse a json string/object in NewtonSoft package

  • Newtonsoft.Json.Linq.JObject
  • Newtonsoft.Json.JsonConvert.DeserializeObject

what is different between these and when we can use it?

Views: 8363
Total Answered: 1
Total Marked As Answer: 1
Posted On: 10-Mar-2016 08:02

Share:   fb twitter linkedin
Answers
Rahul Maurya
Rahul M...
Moderator
1170 Points
210 Posts
Marked as answer      

Hi Priya,

The LINQ-to-JSON API (JObject, JToken, JArray etc.) is to allow working with JSON without need to know its structure. You can deserialize any arbitrary JSON using JToken.Parse, JObject.Parse, JArray.Parse then examine and manipulate its contents using other methods. LINQ-to-JSON also works well if you just need one or two or more values from the JSON (such as the name of a county).

JsonConvert.DeserializeObject, on the other hand, is mainly intended to be used when you know the structure of the JSON and you want to deserialize into strongly typed classes.

Posted On: 25-Mar-2016 01:17
banner

Blog

Active User (2)

 Log In to Chat