json获取关键名称作为文本? [英] json get key names as text?
本文介绍了json获取关键名称作为文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道json值的关键。
I would like to find out the key of a json value.
我在做什么
for(var i in rows){
for(var j in rows[i]){
console.log('value: ', rows[i][j]);
}
}
但我希望能够做到像
for(var i in rows){
for(var j in rows[i]){
console.log('key: rows[i][j].key', 'value: ',rows[i][j]);
}
}
或者什么是
所以我可以访问key。
or whatever so I can access the key.
推荐答案
当您使用(var i in rows)的语法时,我实际上是关键所以你应该能够执行:
When you use the syntax for(var i in rows) i is actually the key so you should be able to do:
console.log('key: ',j, ' value: ',rows[i][j]);
这篇关于json获取关键名称作为文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文