用符号符号解析JSON w / @(arobase) [英] Parsing JSON w/ @ at sign symbol in it (arobase)
本文介绍了用符号符号解析JSON w / @(arobase)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的JSON对象评估为:
My JSON object evaluates to:
{ "@io": IO, "@type": XXX }
如果此变量名为 my_json
,我该怎么办?访问XXX的 @type
值?我尝试了 my_json。@ type
,但这是错误的。帮助赞赏。谢谢,
If this variable is called my_json
, how do I access the @type
value of XXX? I tried my_json.@type
, but this is giving errors. Help appreciated. Thanks,
尼克
推荐答案
使用带有字符串的方括号表示法:
Use square bracket notation with a string:
var XXXValue = my_json['@type'];
当变量中有属性名称时,可以使用相同的值。使用相同的示例:
The same can be used when you have a property name in a variable. Using your same example:
var propertyName = '@type';
var XXXValue = my_json[propertyName];
这篇关于用符号符号解析JSON w / @(arobase)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文