c# - JSON parse exception using System.Json -
i error while parsing json string object. using system.json parse json string.
the json file: (note: cannot change structure of json file because generated)
{ title: "my title", log: "", nid: "1234", type: "software", language: "en", created: "1364480345", revision_timestamp: "1366803957", body: { und: [ { value: "abc", summary: "def" } ] } }
the c# code:
string jsonstring = new webclient().downloadstring(".......myjson.json"); //for test purpose var obj = jsonobject.parse (jsonstring); ///<--- @ line exception thrown
the exception:
system.argumentexception has been thrown. invalid json string literal format. @ line 1, column 2
how solve this?
thanks in advance!
how solve this?
(note: cannot change structure of json file because generated)
easy, use json.net. works without problem json
var j = jobject.parse(jsonstring);
you can use dynamic
keyword
dynamic j = jobject.parse(jsonstring); console.writeline("{0},{1}", j.title, j.body.und[0].value);
Comments
Post a Comment