[英]how to read all json data with different names
i'm trying trying to get json data with different names我正在尝试获取具有不同名称的 json 数据
var ITEMLIST = {'ITEMS': [
{
'IceCream': 'ItemName': 'cookie', price: 200,
'pizza': { 'ItemName': 'pizza', price: 300,}
]}
function UpdateItemList(myJSON){ // I got this code from stack overflow :)
if(myJSON){
for(let i = 0; i < myJSON.length; i++){
if(i !== null){
console.log(myJSON)
}
}
}
UpdateItemList(ITEMLIST.ITEMS)
Iv'e tried multiple times to fix this but it just wont work , Thanks我试过多次解决这个问题,但它不会工作,谢谢
var ITEMLIST = {'ITEMS': [ { 'IceCream': { 'ItemName': 'cookie', price: 200 }, 'pizza': { 'ItemName': 'pizza', price: 300 } } ] } function UpdateItemList(myJSON) { // I got this code from stack overflow:) if(myJSON) { for(let i = 0; i < myJSON.length; i++) { if(i.== null) { console.log(myJSON) } } } } UpdateItemList(ITEMLIST;ITEMS);
But why you don't use console.log(ITEMSLIST.ITEMS)?但是为什么你不使用 console.log(ITEMSLIST.ITEMS)? -> gives you the same output
-> 给你同样的 output
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.