Accessing elements of JSON object without knowing the key names

后端 未结 5 1212
礼貌的吻别
礼貌的吻别 2020-11-30 10:00

Here\'s my json:

{\"d\":{\"key1\":\"value1\",
      \"key2\":\"value2\"}}

Is there any way of accessing the keys and values (in javascript)

5条回答
  •  旧巷少年郎
    2020-11-30 10:20

    Use for loop to achieve the same.

    var dlist = { country: [ 'ENGLAND' ], name: [ 'CROSBY' ] }
    
    for(var key in dlist){
         var keyjson = dlist[key];
         console.log(keyjson)
       }

提交回复
热议问题