JSON.NET

JSON.net and Deserializing Anonymous Types

I had a situation where I had to deserialize a small chunk of JSON-formatted data and I didn’t want to create a class for it since it was a very specific use and I was confident there wasn’t a need to reuse it elsewhere in the application. If I did have a class defined for the JSON data, I could easily use JSON.NET’s JsonConvert.DeserializeObject method: 1: string myJson = "[{id: 10, typeID: 4},{id: 100, typeID: 3}]"; 2: MyObject obj = JsonConvert.DeserializeObje... 3: Console.WriteLine(obj[0].id); ......

«August»
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456