Reputation: 1401
I am trying to parse this text coming from server
var s = "{\"server\":DSL01,\"item\":101,\"data\":[[1357849366000,null],[1357849485000,null]}";
JSON.parse(s);
In the console I get following error, Unexpected token D
I need to convert this into a json object.
Upvotes: 0
Views: 5231
Reputation: 119877
Because DSL01
should be a string, and therefore wrapped in ""
"{\"server\":\"DSL01\",\"
Also, you lack a ]
on the last part, for closing data
array.
I suggest you programmatically create your JSON rather than hand-crafting it. That way, you don't make such errors.
Upvotes: 3