特定の配列の各オブジェクトにidを割り当てることでJSONを再構築しようとしています。このIDは、既存のキー値(osm_id)を使用して作成されます。jqを使用してJSONキー値からオブジェクトIDを作成
これは私の入力です:
[
{
"geometry" : {
"coordinates" : [ -0.7118478, 51.0930284 ],
"type" : "Point"
},
"properties" : {
"osm_id" : "262661",
"religion" : "christian"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [ -0.7207513, 51.0897118 ],
"type" : "Point"
},
"properties" : {
"denomination" : "catholic",
"osm_id" : "262662",
"religion" : "christian"
},
"type" : "Feature"
}
]
これは私の所望の出力です:
[
"262661": {
"geometry": {
"coordinates": [
-0.7118478,
51.0930284
],
"type": "Point"
},
"properties": {
"osm_id": "262661",
"religion": "christian"
},
"type": "Feature"
},
"262662": {
"geometry": {
"coordinates": [
-0.7207513,
51.0897118
],
"type": "Point"
},
"properties": {
"denomination": "catholic",
"osm_id": "262662",
"religion": "christian"
},
"type": "Feature"
}
]
私はデータを更新するJQで動作するようにしようとしてきたが、私は把握することはできませんその最上位IDをどのように割り当てるか。これまでのところ私は持っています
.[] |= {geometry, properties, type}
しかし、それ以上のエラーが発生します。
何か助けていただきありがとうございます。
? –