c# - Valid JSON string throws Unexpected character encountered error -
i'm trying connect angular2 client c# asp.net core server. when i'm sending json string using websockets client server, error:
unexpected character encountered while parsing value: {. path 'argument', line 1, position 39.
the json string follows (the error seems originate opening bracket after "argument:"):
{ "methodname": "createuser", "argument": { "user": { "attributes": [{ "name": "age", "value": "30", "type": 0 }], "email": "test@mail.com", "name": "test name" }, "password": "1234" } }
the code throws error here:
public string receive(string input) { try { debug.writeline(input); instructionserver jsonobject = jsonconvert.deserializeobject<instructionserver>(input); // fails string methodname = jsonobject.methodname; string data = jsonobject.argument; return methods[methodname](1, data, "", ""); } catch (exception e) { return "error: " + e.message; } }
i can't seem figure out error is, because when throw json online json formatter, reports valid json. appreciated.
edit: clarify on valid json. tried printing json string out before sending on client , after receiving on server, , same json string written above.
argument
appears expecting string
, found object. you'll have check format instructionserver
expecting , ensure able deserialize correctly.
Comments
Post a Comment