我有一个json字符串im可以通过简单的eval(string)转换为对象;
heres the sample of the json string:
var json = @'
"{ description" : { "#cdata-section" : "<some html here>" } }
';
var item = eval('('+json+')');
我正在尝试像这样访问它
item.description.#cdata-section
我的问题是javascript不喜欢字段名中的#。是否可以访问它?
最佳答案
item.description['#cdata-section']
关于javascript - 使用奇怪的字符访问Json字段,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1710103/