c# - De-serialize JSON using JSON.net on WP7 -


i'm trying grab json data web service using json.net. error i'm getting unexpected character whilst parsing json data. code i'm using follows:

httpwebrequest request; webresponse response;  private void btnget_click(object sender, routedeventargs e) {     request = webrequest.create(@"http://http://domain.com/test/question.php") httpwebrequest;     request.begingetresponse(afterrequest, null); }  private void afterrequest(iasyncresult result) {     response = request.endgetresponse(result);     using (streamreader sd = new streamreader(response.getresponsestream()))     {         string resultstring = sd.readtoend();          dictionary<string, string> values = jsonconvert.deserializeobject<dictionary<string, string>>(resultstring);         response.close();         messagebox.show(values["question"]);     } } 

the data i'm trying de-serialize is:

{"question":"how old i?","a":"20","b":"23","c":"25","d":"26","z":"d"} 

this data outputted via php/mysql. idea's if it's code or json data that's invalid?

thanks edit: i've updated data i'm trying de-serialize, looks this;{ "question": "how old i?", "answers": { "a": "24", "b": "25", "c": "26", "d": "27" }, "answer": "b" }

your json "valid" poorly formed results looking for. i'd change formatting of json such:

{  "question":"how old i?",  "answers":[    "a":"20",    "b":"23",    "c":"25",    "d":"26",    "z":"d"] } 

by moving possible answers array make easier keep them separated question, , make can extend data set include items such "correctanswer":"b"


Comments