-2

http://ddragon.leagueoflegends.com/cdn/5.7.2/data/en_US/item.json This is how my json data looks like. I would like to parse it. My problem is that in the "data" section, each object ( 1001, 1004, 1006) is a "basic" type :

How do i parse this properly into C# is my question.

YaoFei
  • 1
  • 1
  • Check out http://json2csharp.com/ – Dan Apr 29 '15 at 13:31
  • Make sure you have valid json, copy your json string to http://json2csharp.com/ and it will let you generate a class. Later use JSON.Net *(or any other)* to deserialize json string to object. – Habib Apr 29 '15 at 13:31
  • I have edited my post so my question will be clearer. – YaoFei Apr 29 '15 at 14:21
  • http://stackoverflow.com/questions/26270990/how-to-parse-json-objects-with-numeric-keys-using-javascriptserializer, http://stackoverflow.com/questions/1207731/how-can-i-deserialize-json-to-a-simple-dictionarystring-string-in-asp-net – CodeCaster Apr 29 '15 at 14:23
  • Include the actual JSON in your post, not a picture of it. We can't copy-and-paste from a picture. – Craig W. Apr 29 '15 at 14:24

1 Answers1

0

First create another class:

public class Foo
{
     public List<Basic> Basic{get;set;}
     public string type{get;set;}
     public string version{get;set;}
}

Then use NewtonSoft,

JsonConvert.DeserializeObject<Foo>(inputString)
MRebai
  • 5,344
  • 3
  • 33
  • 52