Skip to main content

Hi all, 

I have a geojson file, where I would like to concatenate the some key value pair to one as array. I have tried ListConcatenator however it simple concatenate without creating array. You can see the below my attempt and desired result. Thanks in advance. 

Output of ListConcatenator

{
            "type" : "Feature",
            "geometry" : {
                "type" : "LineString",
                "coordinates" : Â
                     Â 4.3458008766, 50.8345288033 ],
                     Â 4.346331954, 50.8348774905 ],
                     Â 4.3474423885, 50.8357197041 ]
                ]
            },
            "properties" : {
                "osm_id" : "",
                "osm_way_id" : "30010739",
                "_amenity{0}.amenity" : "hospital",
                "_amenity{1}.amenity" : "pharmacy",
                "_amenity{2}.amenity" : "drinking_water",
                "_amenity{3}.amenity" : "pub",
                "_concatenated" : "hospital,waste_basket,pharmacy,drinking_water,pub"
            }
        }

Desired output 

{
 "type": "Feature",
 "geometry": {
   "type": "LineString",
   "coordinates": Â
     Â
       4.3458008766,
       50.8345288033
     ],
      
       4.346331954,
       50.8348774905
     ],
     p
       4.3474423885,
       50.8357197041
     ]
   ]
 },
 "properties": {
   "osm_id": "",
   "osm_way_id": "30010739",
   "_amenity{0}.amenity": "hospital",
   "_amenity{1}.amenity": "pharmacy",
   "_amenity{2}.amenity": "drinking_water",
   "_amenity{3}.amenity": "pub",
   "_concatenated": 6
     "hospital",
     "waste_basket",
     "pharmacy",
     "drinking_water",
     "pub"
   ]
 }
}

You could try the JSONTemplater to get the desired result


You could try the JSONTemplater to get the desired result

Can you give me some hints? Never used it before and tried once and the results i got like this:

"_array" : "{ \\"amenity\\" : [ \\"parking\\", \\"recycling\\" ] }"


Hi @jugoslaviaa, What writer are you using in your workspace for this? I ran a quick test using the GeoJSON writer directly. If I send the _amenity{} list attribute directly to the writer, it automatically creates an array in the output for me like this:


Hi @jugoslaviaa, What writer are you using in your workspace for this? I ran a quick test using the GeoJSON writer directly. If I send the _amenity{} list attribute directly to the writer, it automatically creates an array in the output for me like this:

I am using also geojson. But it does not get written _amenity{} at all if I do not expose the elements beforehand. Am I missing something?


Reply