我有一个很长的json文件,想从中提取一些信息。这是其中的一些行:
{
"type": "node",
"id": 4000703812,
"lat": -37.8664035,
"lon": 145.029337,
"tags": {
"name": "Malvern",
"name:zh": "墨尔文",
"network": "PTV – Metropolitan Trains",
"operator": "Metro Trains Melbourne",
"public_transport": "stop_position",
"ref": "MAL",
"ref:ptv": "19944",
"train": "yes",
"website": "https://ptv.vic.gov.au/stop/1118",
"wikidata": "Q6745096",
"wikipedia": "en:Malvern railway station, Melbourne"
}
},
{
"type": "node",
"id": 4000703813,
"lat": -37.8664239,
"lon": 145.0293099,
"tags": {
"name": "Malvern",
"name:zh": "墨尔文",
"network": "PTV – Metropolitan Trains",
"operator": "Metro Trains Melbourne",
"public_transport": "stop_position",
"ref": "MAL",
"ref:ptv": "19944",
"train": "yes",
"website": "https://ptv.vic.gov.au/stop/1118",
"wikidata": "Q6745096",
"wikipedia": "en:Malvern railway station, Melbourne"
}
},
{
"type": "way",
"id": 113543936,
"center": {
"lat": -37.7974032,
"lon": 144.9674811
},
"nodes": [
8864592602,
8864592606,
8864592599,
8864592600,
8864592601,
1287222216
],
"tags": {
"area": "yes",
"bus": "yes",
"departures_board": "timetable",
"name": "Elgin Street/Lygon Street",
"network": "PTV - Metropolitan Buses",
"operator": "Transdev",
"public_transport": "platform",
"route_ref": "200;207",
"source": "bing",
"surface": "asphalt",
"tactile_paving": "no"
}
},
{
"type": "way",
"id": 45478351,
"center": {
"lat": -37.7784042,
"lon": 145.0313655
},
"nodes": [
579375498,
5515852169,
579375499
],
"tags": {
"public_transport": "platform",
"railway": "platform"
}
},
{
"type": "way",
"id": 45478438,
"center": {
"lat": -37.7689219,
"lon": 145.0454472
},
"nodes": [
579377100,
579377102
],
"tags": {
"bench": "yes",
"bin": "yes",
"lit": "yes",
"public_transport": "platform",
"railway": "platform",
"ref": "1",
"shelter": "yes",
"tactile_paving": "yes"
}
},
{
"type": "way",
"id": 37892868,
"center": {
"lat": -37.8188306,
"lon": 145.2145215
},
"nodes": [
444681241,
444681237,
444681241
],
"tags": {
"area": "yes",
"departures_board": "realtime",
"foot": "yes",
"layer": "-1",
"network": "PTV – Metropolitan Trains",
"operator": "Metro Trains Melbourne",
"public_transport": "platform",
"railway": "platform",
"ref": "1",
"surface": "asphalt",
"train": "yes"
}
},
我如何存储所有具有tage "type": "way"
的示例,然后进一步将它们分离出来并将它们存储为字典或python列表。我想有一个Bus,Trains,Trams的Three字典,每个字典包含具有bus,train或tram的方式的id以及所有节点的值。例如,在上面的例子中,对于bus,它将是:Busses["id: 113543936"] = [ 8864592602,8864592606,8864592599,8864592600,8864592601,1287222216]
1条答案
按热度按时间8iwquhpp1#
只需循环遍历JSON的所有对象并填充巴士,电车和火车的字典。您还可以根据变量更改类型过滤。