c# - Error converting value "System.Collections.Generic.List`1[]" to type 'WebApiTestDefinition.obJson'. Path '', line 1, position 63 -
i tried deserialize json data showing error this.
public actionresult test(login log) { string sstudname = "ram"; httpclient client = new httpclient(); client.baseaddress = new uri(studentapi); client.defaultrequestheaders.accept.add(new mediatypewithqualityheadervalue("application/json")); // depends on whether want json or xml var loginresp = client.postasjsonasync(studentapi, log).result; if (loginresp.issuccessstatuscode) { //if (loginresp == null) //{ var msg = loginresp.content.readasstringasync(); objson res = jsonconvert.deserializeobject<objson>(loginresp.content.readasstringasync().result); return json(log, jsonrequestbehavior.allowget); //} //return redirect("/admission/registration"); } else { } return view(); }
take @ this question (it refers json.net)
so in case should try (if using json.net possible)
var msg = ""; // json message string dynamic json = jobject.parse(msg); // json
Comments
Post a Comment