需要帮助从Javascript对象中提取数据
Need help to extract data from Javascript object?
你好,我有这个数据:
var data={
"city_id": "2",
"dist": "2",
"City Name 1": [
{
"id": 1,
"name": "name 1",
"address": "address 1",
"tel": "tel 1",
"Radio": "0",
"surgery": "0"
},
{
"id": 2,
"name": "name 2",
"address": "address 2",
"tel": "tel 2",
"Radio": "0",
"surgery": "0"
}
],{
"city_id": "2",
"dist": "2",
"City Name 2": [
{
"id": 1,
"name": "name 1",
"address": "address 1",
"tel": "tel 1",
"Radio": "0",
"surgery": "0"
},
{
"id": 2,
"name": "name 2",
"address": "address 2",
"tel": "tel 2",
"Radio": "0",
"surgery": "0"
}
]
}
};
我想通过这个JSON数据循环提取City_id, dist_id, City Name,然后另一个循环获取姓名,地址和电话。数据格式不正确,我不知道如何修复。
我很感激你的帮助。谢谢你你的括号关闭了,使得这不是一个有效的json。
var data={ //------------------------------------open
"city_id": "2",
"dist": "2",
"City Name 1": [
{//----------------------open
"id": 1,
"name": "name 1",
"address": "address 1",
"tel": "tel 1",
"Radio": "0",
"surgery": "0"
},//----------------------close
{//-----------------------open
"id": 2,
"name": "name 2",
"address": "address 2",
"tel": "tel 2",
"Radio": "0",
"surgery": "0"
}//----------------------close
],{//----------------------------------open (problem is here. There is nothing index this object}
"city_id": "2",
"dist": "2",
"City Name 2": [
{//-----------------------open
"id": 1,
"name": "name 1",
"address": "address 1",
"tel": "tel 1",
"Radio": "0",
"surgery": "0"
},//----------------------close
{//-----------------------open
"id": 2,
"name": "name 2",
"address": "address 2",
"tel": "tel 2",
"Radio": "0",
"surgery": "0"
}//----------------------close
]
}//----------------------------------close
}; //------------------------------------------------close
该位需要在数组中或从json.
相关文章:
- 如何使用另一个字符串作为模板从字符串中提取数据
- 如何使用angular js从2个表(在sql server中)中提取数据
- 从Angular 2中的observable中提取数据
- Mongoose查询在两个日期时间之间提取数据
- 可以't从xml文件中提取数据
- 从HTML代码中提取数据
- 使用JavaScript或AJAX从HTML表单中提取数据,然后将其传递给PHP
- 正在从JSON.stringify中提取数据
- Scrapy和Xpath从javascript代码中提取数据
- 如何从高股价图中提取数据
- 如何在javascript中使用localStorage从数组中存储和提取数据
- 如何从Promise中提取数据
- 为什么我的Backbone Collection没有提取数据
- 从jQuery变量中提取数据,增加's left,将剥离的数据放回变量中
- 如何使用应用程序脚本执行API从谷歌工作表中提取数据
- 使用ng repeat从两个不同的JSON文件中提取数据
- 创建新的javascript数组,从对象属性中提取数据
- 如何使用 jQuery 在没有类的情况下提取数据
- 使用javascript从JSON中提取数据
- React组件从Flux存储中呈现数据,但从Mongo数据库中提取数据时不呈现