How can I parse JSON with C#? -
i have following code
var user = (dictionary<string, object>)serializer.deserializeobject(responsecontent);
the input in responsecontent
json, not parsed json object. how should serialize it?
i assuming not using json.net. if case, should try it.
it has following features:
- linq json
- the jsonserializer converting .net objects json , again
- json.net can optionally produce formatted, indented json debugging or display
- attributes jsonignore , jsonproperty can added class customize how class serialized
- ability convert json , xml
- supports multiple platforms: .net, silverlight , compact framework
look @ example below. in example, jsonconvert
class used convert object , json. has 2 static methods purpose. serializeobject(object obj)
, deserializeobject<t>(string json)
:
product product = new product(); product.name = "apple"; product.expiry = new datetime(2008, 12, 28); product.price = 3.99m; product.sizes = new string[] { "small", "medium", "large" }; string json = jsonconvert.serializeobject(product); //{ // "name": "apple", // "expiry": "2008-12-28t00:00:00", // "price": 3.99, // "sizes": [ // "small", // "medium", // "large" // ] //} product deserializedproduct = jsonconvert.deserializeobject<product>(json);
Comments
Post a Comment