Skip to main content

 

 

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": t
            "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
            }
        ]
    }

 

Hi @robertdbuckley

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

 

Thanks in Advance,

Danilo


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.


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

     


  • 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.


    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.


  • A fuller answer now exists as the Question of the Week at: https://knowledge.safe.com/questions/109319/question-of-the-week-flattening-nested-json-attrib.html


    Reply