简体   繁体   中英

How to access JSON object 'key' dynamically without using [key]?

For example, my json object is:

var obj = {
  a:'aerereasr',
  b:'xxxxxx',
  cc:12345
}

let say, if I want to dynamically access or change the value of each key, I normally do this:

for (var key in obj) {
  obj[key] = 'new value';
}

is there alternative way for obj[key] ?

不,不是没有使用eval()或调用eval()东西eval()如解释)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM