3

I am querying data from http://www.imdbapi.com and would like to parse the result using Json.net library. Could someone please tell me how I can use this library to convert the query response into a Map<string, string>.

With this code I'm able to get all keys, but how can query the values then?

   JObject obj = JObject.Parse(response);
   IList<string> props = obj.Properties().Select(p => p.Name).ToList();
2
  • Horrible title, BTW. Could you not think of anything to ask about "JSON Parser"? Commented Nov 11, 2011 at 18:20
  • sorry, I'll consider it next time. Commented Nov 11, 2011 at 18:32

2 Answers 2

8

Try JSON.NET

Just use this:

Dictionary<string, string> movieValues = 
     JsonConvert.DeserializeObject<Dictionary<string, string>>(responseFromImdbApi);

Just get the values like this:

movieValues["title"] 
movieValues["released"]
movieValues["genre"]
Sign up to request clarification or add additional context in comments.

Comments

0

Why would you use an external library when it is already available ?

JavaScriptSerializer works great.

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.