Solved

Trying to create features from JSON (following JSONFragmenter)

  • 11 August 2017
  • 5 replies
  • 28 views

I'm trying to create (FME-)features from a JSON-ouput (source: JSONFragmenter).

I am not able to subtract/expose "geometry" and can't figure out why.

My JSONFragmenter parameters are:

JSON Query: json["features"][*]

Attributes to expose: id geometry

Can someone help me out ?

0684Q00000ArD10QAF.jpg

Example of JSON-output:

{
    "type": "FeatureCollection",
    "totalFeatures": 1681523,
    "features": [
        {
            "type": "Feature",
            "id": "GBG.23662",
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            134465.638337,
                            192310.473928
                        ],
                        [
                            134465.881025,
                            192308.624072
                        ],
                        [
                            134470.076353,
                            192309.29684
                        ],
                        [
                            134470.049217,
                            192308.49812
                        ],
                        [
                            134474.971585,
                            192308.162248
                        ],
                        [
                            134475.428289,
                            192311.290056
                        ],
                        [
                            134472.498625,
                            192311.514824
                        ],
                        [
                            134472.445377,
                            192310.982344
                        ],
                        [
                            134470.684609,
                            192311.168712
                        ],
                        [
                            134465.638337,
                            192310.473928
                        ]
                    ]
                ]
            },
            "geometry_name": "SHAPE",
            "properties": {
                "UIDN": 334345,
                "OIDN": 294586,
                "TYPE": 2,
                "LBLTYPE": "bijgebouw",
                "OPNDATUM": "2005-09-05",
                "bbox": [
                    134465.638337,
                    192308.162248,
                    134475.428289,
                    192311.514824
                ]
            }
        },

icon

Best answer by takashi 11 August 2017, 16:07

View original

5 replies

Userlevel 5
Badge +25

I don't have an immediate answer for you, but it looks like the output might be similar to what's discussed here.

Userlevel 2
Badge +17

Hi @sdv, you have to flatten the JSON fragment to extract the members. Check these parameters in the JSONFragmenter.

  • Flatten Query Result into Attributes: Yes
  • Recursively Flatten Objects/Arrays: Set "Yes" if you need to flatten all descendant objects, "No" otherwise (flatten only one-level).

By the way, the document seems to be a GeoJSON dataset. You can also read it with the GeoJSON reader as features having a geometry and a set of attributes.

I don't have an immediate answer for you, but it looks like the output might be similar to what's discussed here.

Thank you for following up my question redgeographics . Indeed I have tried to study that topic to put me on the right track !

 

 

Hi @sdv, you have to flatten the JSON fragment to extract the members. Check these parameters in the JSONFragmenter.

  • Flatten Query Result into Attributes: Yes
  • Recursively Flatten Objects/Arrays: Set "Yes" if you need to flatten all descendant objects, "No" otherwise (flatten only one-level).

By the way, the document seems to be a GeoJSON dataset. You can also read it with the GeoJSON reader as features having a geometry and a set of attributes.

@takashi

 

 

This is how my workbench looks now

 

Now I'm able to see a 'geometry' field.

 

 

Just one (stupid...) question: can I use the FeatureReader to read the outcome of the JSONFragmenter ? I'm quite new to FME + can't seem to configure the FeatureReader for my purposes. Thanks !

 

 

Userlevel 2
Badge +17

Hi @sdv, you have to flatten the JSON fragment to extract the members. Check these parameters in the JSONFragmenter.

  • Flatten Query Result into Attributes: Yes
  • Recursively Flatten Objects/Arrays: Set "Yes" if you need to flatten all descendant objects, "No" otherwise (flatten only one-level).

By the way, the document seems to be a GeoJSON dataset. You can also read it with the GeoJSON reader as features having a geometry and a set of attributes.

If you intend to read the dataset as a GeoJSON document, I think just a single FeatureReader is what you need. Try connecting this FeatureReader to the CSV reader feature type directly.

 

 

Reply