JSON - Access field named '*' asterisk

前端 未结 4 2163
南笙
南笙 2020-12-17 23:27

I am trying to access a field in a json object in javascript which has the key \'*\'. The jsonstring looks like this:

{\"parse\":
 {\"text\":
  {\"*\":\"text         


        
相关标签:
4条回答
  • 2020-12-17 23:43

    try to use

    var text = myObject.parse.text['*']
    
    0 讨论(0)
  • 2020-12-17 23:55

    You could do:

    var json = {"parse":
     {"text":
      {"*":"text i want to access"}
     }
    }
    
    alert(json.parse.text['*']);
    
    0 讨论(0)
  • 2020-12-18 00:00

    Try use the index operator on parse.text:

    var value = object.parse.text["*"];
    
    0 讨论(0)
  • 2020-12-18 00:08
    json.parse.text["*"]
    

    Yucky name for an object member.

    0 讨论(0)
提交回复
热议问题