json keys as numbers

后端 未结 1 1201
暗喜
暗喜 2021-01-04 18:15

I have a JSON passed to script. I do not know JSON keys as they are dynamic.

Actually, they are numbers. That\'s what I\'m getting.

var countries = {\"223         


        
相关标签:
1条回答
  • 2021-01-04 18:36

    Instead of this:

    countries.objKey;
    

    Do this:

     countries[objKey];
    

    With square bracket notation, you can use the value referenced in a variable (or use a string or number) to reference the property name.

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