Geeks With Blogs
The Reluctant Blogger Blogging not because I have to, but because I want to 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); ......

Posted On Friday, January 6, 2012 1:08 PM

Copyright © David Hoerster | Powered by: | Join free