Question

Struggling to extract all the flattened JSON features using the JSONFragmenter

  • 9 February 2022
  • 1 reply
  • 2 views

Hi all,

 

I am trying to extract the following attributes from my JSON file: "area": "perimeter""laFeatureType" (plus some others) from the attached JSON file.

 

I am using a JSONFragmenter with the query json["data"][*]  but it isn't extracting as expect (all returns with "missing" data although I can see the data within the JSON file) .

Screen shot of my fragmenter attached.

 

Any help much appreciated.

 

Thanks

 


1 reply

Userlevel 6
Badge +31

The reason this does not work is the _response_body is not valid json. I think it is RTF, (Rich Text Format). Not sure how to process this in FME. I found an 8 year old answer where a Python solution was proposed to convert to plain text.

 

If I manually remove all jibber jabber in rows 1 to 7, the first part of row 8, and all backslashes I get valid json:

{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[214452.89, 69869.19],
[214453.1, 69875.93],
[214422.76, 69899.66],
[214420.04, 69901.23],
[214406.35, 69909.14],
[214378.85, 69921.14],
[214323.39, 69940.64],
[214290.01, 69864.87],
[214283.38, 69853.43],
[214277.23, 69843.87],
[214275.15, 69840.56],
[214265.68, 69820.38],
[214260.82, 69804.28],
[214255.65, 69772.41],
[214253.38, 69760.59],
[214254.02, 69757.16],
[214254.38, 69755.67],
[214254.94, 69754.13],
[214255.64, 69752.6],
[214255.73, 69752.41],
[214256.579, 69751.496],
[214257.3, 69750.72],
[214258.36, 69749.67],
[214258.7, 69749.446],
[214262.04, 69747.24],
[214275.44, 69739.24],
[214276.88, 69738.41],
[214287.06, 69732.52],
[214299.38, 69724.78],
[214301.07, 69723.75],
[214309.93, 69720.06],
[214323.27, 69714.3],
[214329.44, 69711.42],
[214340, 69707.71],
[214343.59, 69706.37],
[214345.79, 69705.74],
[214351.41, 69704.5],
[214358.2, 69702.8],
[214364.4, 69713.59],
[214376.02, 69733.82],
[214404.64, 69784.7],
[214432.67, 69834.29],
[214452.89, 69869.19]
],
[
[214379.823, 69841.291],
[214384.247, 69844.056],
[214387.025, 69839.611],
[214382.601, 69836.846],
[214379.823, 69841.291]
]
]
]
},
"properties": {
"id": 5199540,
"area": 28443.122295000387,
"perimeter": 683.4246300438173,
"versiondate": "2017-08-14T00:00:00.000Z",
"make": "Natural",
"descriptivegroup": ["General Surface"],
"descriptiveterm": ["Agricultural Land"],
"laFeatureType": "g"
},
"id": "84252413-32f8-4700-948a-4a5a3d2c9ace"
}

I often use JSONlint to fix this stuff manually.

 

Edit: I have only one rtf sample, but my guess is that the data is always in the last row. So you could read it with a text reader, keep only the last row, remove everything before the first "{", remove all backslashes...

Reply