I do an HTTP GET request to get a json string. I get back someting like {"a":2,"b":3,"c":3}
. I know this because I can run console.lo开发者_运维问答g on it, and get my nice JSON string. However, when I try to parse it with JSON.parse I get something like {0:123,1:63,...}
. Basically, it shows the ascii values of my string rather than parsing the JSON object. Why is this happening?
Code:
var jsonString = '{"a":2,"b":3,"c":3}';
var object = JSON.parse(jsonString);
console.log(object);
console.log(object.a);
console.log(object['b']);
Output:
{ a: 2, b: 3, c: 3 }
2
3
A more specific example of your problem would be helpful, as something else is obviously going on.
精彩评论