声明一个三层的json对象作为测试:
var js={
"text":"MXCHIP won a prize",
"id": 1234,
"detail":{
"comp": "MXCHIP.Inc",
"from":"ShangHai",
"focus":"Internet of Things",
"module":[{"k":"EMW3165"},{"k":"EMW3166"},{"k":"EMW3031"},{"k":"EMW3239"}]
}
}
递归取值函数:(key为键名,sign为各级别键名之间的分隔符)
function printValue(js,key,sign){
if(key == ""||key == undefined){
key="json"
}
for(p in js){