Skip to main content
Question

How to tranform json results into shapefile?


Forum|alt.badge.img

 

 

In the following snippet (which has been reduced in length from the above file) are the results from a web api. I need to create a point for every coordinate pair and add the relevant attribute data to the point table. I am having problems due to the ID of each feature e.g. "535412" which envelopes the other attributes.

 

How can I manipulate the json file to be able to write a shapefile with the attributes as fields?

{

        "Results": [
            "535412": {
                "Standortbescheinigungsnummer": "021296",
                "PostalischeAdresse": "Gstraße 8, 35560 Musterort",
                "Standortbescheinigungsdokumente": {
                    "AktuellsteStandortbescheinigungsdokumente": {
                        "STOB": "15ba5116-be92-4c61-8a72-22d605b70f",
                        "TD": "e3452231-0f4f-4d10-8b38-40386acd1a"
                    }
                },
                "KOORD_NORD_DEZ": 53.117221,
                "KOORD_OST_DEZ": 9.791388
            },
            "545123": {
                "Standortbescheinigungsnummer": "021626",
                "PostalischeAdresse": "VStraße 32, 23994 Musterort",
                "Standortbescheinigungsdokumente": {
                    "AktuellsteStandortbescheinigungsdokumente": {
                        "STOB": "70da0d00-2e18-4427-acd7-f8c2e9f11e"
                    }
                },
                "KOORD_NORD_DEZ": 53.134722,
                "KOORD_OST_DEZ": 9.769166
            }
        ]
    }

 

6 replies

danilo_fme
Evangelist
Forum|alt.badge.img+44
  • Evangelist
  • March 6, 2020

Hi @robertdbuckley

DId you try to use the transformer JSONGragmenter and expose the attributes:

 

Thanks in Advance,

Danilo


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • March 6, 2020

Tricksy.

I expect you'll have to use x-query fn:node-name to extract the id as a value rather than an attribute name.


esietinga
Contributor
Forum|alt.badge.img+4
  • Contributor
  • March 6, 2020

I replaced the square brackets "[" and "]" with curly braces ( "{" and "}" respectively with two string replacers. Then use an JSONFragmenter (JSON Query: json[*][*], recursive flatten objects? No) and expose the required attributes. Rename attributes as required

examplejson.fmw

 


Forum|alt.badge.img
esietinga wrote:

I replaced the square brackets "[" and "]" with curly braces ( "{" and "}" respectively with two string replacers. Then use an JSONFragmenter (JSON Query: json[*][*], recursive flatten objects? No) and expose the required attributes. Rename attributes as required

examplejson.fmw

 

Unfortunately I can't get this to work adaquately.


mark2atsafe
Safer
Forum|alt.badge.img+44

Try json["Ergebnisliste"][*] in the JSONFragmenter. Set Flatten Query Results into Attributes = Yes.

Then you should get one FME feature per ID number, and the NORD and OST coordinates are exposed.


mark2atsafe
Safer
Forum|alt.badge.img+44

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings