Skip to main content
Solved

Trying to create features from JSON (following JSONFragmenter)


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
                ]
            }
        },

Best answer by takashi

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.

View original
Did this help you find an answer to your question?

5 replies

redgeographics
Celebrity
Forum|alt.badge.img+49

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


takashi
Influencer
  • Best Answer
  • August 11, 2017

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.


  • Author
  • August 11, 2017
redgeographics wrote:

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 !

 

 


  • Author
  • August 11, 2017
takashi wrote:

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 !

 

 


takashi
Influencer
  • August 11, 2017
takashi wrote:

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.

 

 


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