解析JSON数值时出现问题

时间:2013-10-17 05:15:20

标签: json

我有一个从服务器返回的JSON值。我可以解析这个值。找到以下JSON值

{"Result":{"d8bf6ab7-21a2-4964-a2cf-e7a1db097f08_FROM":"FROM"}}

如果我试图获得像

这样的值
console.log(Result.d8bf6ab7-21a2-4964-a2cf-e7a1db097f08_FROM);
console.log(Result[d8bf6ab7-21a2-4964-a2cf-e7a1db097f08_FROM]);

抛出错误

SyntaxError: identifier starts immediately after numeric literal

1 个答案:

答案 0 :(得分:1)

试试这个:

var obj = {"Result":{"d8bf6ab7-21a2-4964-a2cf-e7a1db097f08_FROM":"FROM"}};

console.log(obj.Result["d8bf6ab7-21a2-4964-a2cf-e7a1db097f08_FROM"]);