我有一个函数,可以获取一个包含对象的JSON数组。在函数中,我将能够循环遍历数组,访问属性并使用该属性。就像这样:
我将传递给函数的变量将类似于此:
[{
"id": 28,
"Title": "Sweden"
}, {
"id": 56,
"Title": "USA"
}, {
"id": 89,
"Title": "England"
}]
function test(myJSON) {
// maybe parse my the JSON variable?
// and then I want to loop through it and access my IDs and my titles
}
有什么建议可以解决这个问题吗?