关于“对象转换为数组php”的问题,小编就整理了【1】个相关介绍“对象转换为数组php”的解答:
如何把JSON对象转成数组?var jsonOb = { "1": "a", "2": "b", "3": "c" }
; var newJson = "{\"context\":["
; for (var key in jsonOb) { newJson+="{\""+key+"\":\""+jsonOb[key]+"\"},"
; console.log(key + ":" + jsonOb[key]); } newJson = newJson.substring(0,newJson.length-1); newJson += "]}"
; console.log(newJson)
; newJson = JSON.parse(newJson)
; for(var i in newJson.context){ for(var key in newJson.context[i]){ console.log(key +":"+newJson.context[i][key]); } }要取数组的话自己提出来就行了
到此,以上就是小编对于“对象转换为数组php”的问题就介绍到这了,希望介绍关于“对象转换为数组php”的【1】点解答对大家有用。