可能重复:
从 JSON.parse 数组中获取数据
我是 json 的新手,甚至不知道问题标题是否正确
我在 obj 中有以下语句 'obj = ko.toJSON(viewModel)';viewmodel 是一个淘汰视图。
{
"activeColumns": [
{
"property": "delete",
"display": "Delete",
"checked": true,
"readonly": true
},
{
"property": "id",
"display": "ID",
"checked": false,
"readonly": true
},
{
"property": "name",
"display": "Name",
"checked": false,
"readonly": false
},
{
"property": "age",
"display": "Age",
"checked": false,
"readonly": false
}
],
"rows": [
{
"selectedFruits": [],
"id": 1,
"name": "Bob",
"age": 44
},
{
"selectedFruits": [],
"id": 2,
"name": "Ted",
"age": 22
},
{
"selectedFruits": [],
"id": 3,
"name": "Jane",
"age": 55
},
{
"selectedFruits": [],
"id": 4,
"name": "Sue",
"age": 11
}
],
"newName": "",
"lastSavedJson": "",
"newAge": "",
"newAttribute": "",
"males": 10,
"females": 90,
"val": 50,
"selectedValue": "select",
"selectedCategory": "select",
"availablecategory": [
"select",
"functional",
"non-functional",
"technical"
],
"tshirtoptions": [
"select",
"S",
"M",
"L",
"XL",
"XXL"
],
"availableparametertype": [
"select",
"range",
"numeric",
"percentage",
"t-shirt"
]
}
我正在使用 obj.activeColumns()[0] 访问第一个数组,但它显示未捕获的类型错误。如何访问不同的对象数组及其属性,然后在如何删除特定对象之后。谢谢...