Accessing Json fields with weird characters

后端 未结 3 2018
醉话见心
醉话见心 2020-12-17 03:24

i have a json string im converting to object with a simple eval(string);

heres the sample of the json string:
var json = @\'
\"{ description\" : { \"#cdata-s         


        
3条回答
  •  借酒劲吻你
    2020-12-17 04:00

    Remember that all Javascript objects are just hash tables underneath, so you can always access elements with subscript notation.

    Whenever an element name would cause a problem with the dot notation (such as using a variable element name, or one with weird characters, etc.) just use a string instead.

    var cdata = item.description["#cdata-section"];
    

提交回复
热议问题