How do I get a value from a JObject?

How do i parse json?

  • I am using Newtonsoft Json library to parse json but i don't know how to use it. I parsed the string using JObject. When i output the value of JObject instance in immediate window i get this :- json { "data": [ { "id": "id", "from": { "name": "name", "id": "someotherid" }, "name": "pic", "description": "desc", "link": "linktosite", "privacy": "everyone", "count": 1, "type": "normal", "created_time": "2010-10-22T14:54:32+0000", "updated_time": "2010-10-22T14:55:41+0000" }, { "id": "id2", "from": { "name": "name", "id": "someotherid" }, "name": "Profile Pictures", "link": "link", "privacy": "everyone", "count": 6, "type": "profile", "created_time": "2010-10-12T14:27:58+0000", "updated_time": "2011-01-01T18:38:14+0000" }, { "id": "id3", "from": { "name": "name", "id": "829741958" }, "name": "T", "link": "link", "privacy": "everyone", "count": 5, "type": "normal", "created_time": "2010-05-01T03:03:39+0000", "updated_time": "2010-05-01T03:19:13+0000", "comments": { "data": [ { "id": "id", "from": null, "message": "message", "created_time": "2010-08-28T18:27:10+0000", "likes": 1 } ] } } ], "paging": { "previous": "paginglink", "next": "otherpaginglink" } } Count: 2 Type: Object What should i do further to have the values from this jobject?

  • Answer:

    I personally prefer the http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx for use with JSON in the .NET environment. By default it will return a Dictionary result, but can be used to parse in to a custom object (or you could make use of the dynamic datatype). http://stackoverflow.com/search?q=javascriptserializer+json

TCM at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

I found this answer in previous queries for the same topic: http://stackoverflow.com/questions/401756/parsing-json-using-json-net

brianestey

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.