My TopoJSON file contains multiple geometries, structured as follows:
{
"type": "Topology",
"objects": {
"delegaciones": {
"geometries": [
{
"properties": {
"name": "Tlalpan",
"municip": "012",
"id": "09012",
"state": "09"
}
...
I am looking to extract the id
field from the properties
, and assign it to the parent object. The desired result is:
{
"type": "Topology",
"objects": {
"delegaciones": {
"geometries": [
{
"id": "09012",
"properties": {
"name": "Tlalpan",
"municip": "012",
"id": "09012", // <-- It's okay if it's removed or not
"state": "09"
}
...
I attempted the following assignment using jq, but it was unsuccessful:
jq '.objects.delegaciones.geometries[].id = .objects.delegaciones.geometries[].properties.id' topo_df.json
Does anyone know how to iterate elements one by one in jq? Or any alternative method to achieve this task?