Solved

Json flattener and extractor


Badge

Hi All. my first delve into reading Json, i have read all the fme material and help sections about using the text file reader then json flattener then list exploder but cant seem to have any success. Im trying to read each "feature" and obtain its "properties" then create a geom from its "coordinates" 

i can read the "size", "mimeType", "compression" and "text" values but i cant drill down any further in the "text" object. I have tried JsonFlattener with exposing attributes features.properties{}, text.feature.properties{} but no list get generated for the Listexploder. Any help or suggestions on how to move forward would be much appreciated @takashi. Many thanks Steve

{
"size": 100038,
"mimeType": "application/json",
"compression": 0,
"text": "{\"features\":[{\"properties\":{\"carNumber\":\"R327410 (Preliminary)\",\"carStatus\":\"Start Notification Overdue\",\"activity\":\"Installing other structure/s (Specify Below)\",\"applicant\":\"PARALLAXX LIMITED\",\"contact\":\"Dave Tilton, (W) 0800333772, (E) dave@parallaxx.co.nz\",\"duration\":\"365 day(s) from 21/04/2016 to 20/04/2017\",\"workStart\":\"03/05/2016 Proposed\",\"workComplete\":null},\"geometry\":{\"coordinates\":[[[174.76574152708054,-36.842971068143072],[174.76602047681809,-36.84304404990008],[174.76694315671921,-36.843288752929993],[174.76348310709,-36.851148884538183],[174.76164311170578,-36.850535042071883],[174.76347237825394,-36.846396842572261],[174.7645291686058,-36.844181697694985],[174.7651943564415,-36.842829397474745],[174.7657898068428,-36.842988240327458],[174.76574152708054,-36.842971068143072]]],\"shapeType\":\"Polygon\",\"type\":\"Polygon\"},\"type\":\"Feature\"},

{\"properties\":{\"carNumber\":\"E332658 (Non Excavation)\",\"carStatus\":\"New\",\"activity\":\"Cable Works/Hauling/Splicing\",\"applicant\":\"VISIONSTREAM PTY LIMITED\",\"contact\":\"Michelle Chapman, (W) 093591306, (E) michelle.chapman@visionstream.co.nz\",\"duration\":\"7 day(s) from 12/05/2016 to 08/06/2016\",\"workStart\":\"12/05/2016 Proposed\",\"workComplete\":null},\"geometry\":{\"coordinates\":[[[174.76405441761017,-36.8423743323403],[174.76817429065704,-36.843378906480467],[174.76749837398529,-36.84511326837913],[174.76321756839752,-36.843919825551247],[174.76387202739716,-36.842451607742689],[174.76405441761017,-36.8423743323403]]],\"shapeType\":\"Polygon\",\"type\":\"Polygon\"},\"type\":\"Feature\"}
}


icon

Best answer by takashi 14 May 2016, 08:47

View original

4 replies

Userlevel 2
Badge +17

Hi @goatboy, it seems that the value of "text" is a GeoJSON object, but its syntax is invalid. Is your posted document correct? I think the last two line should be as:

\":\"Feature\"}]}"
}

Assuming that my correction is correct, the attached workspace would be a solution: parse-embedded-geojson-example.fmw (FME 2016.1)

Badge

Hi @goatboy, it seems that the value of "text" is a GeoJSON object, but its syntax is invalid. Is your posted document correct? I think the last two line should be as:

\":\"Feature\"}]}"
}

Assuming that my correction is correct, the attached workspace would be a solution: parse-embedded-geojson-example.fmw (FME 2016.1)

Many Thanks @takashi . Yes i think i truncated the syntax when i copied the document... i will try your workbench and report back. thanks again, Steve

Userlevel 2
Badge +17

Hi @goatboy, it seems that the value of "text" is a GeoJSON object, but its syntax is invalid. Is your posted document correct? I think the last two line should be as:

\":\"Feature\"}]}"
}

Assuming that my correction is correct, the attached workspace would be a solution: parse-embedded-geojson-example.fmw (FME 2016.1)

@goatboy, you can remove one JSONFlattener from the previous example, by setting Flattening Parameters in the JSONFragmenter. See this update: parse-embedded-geojson-example-2.fmw (FME 2016.1)

Badge

Hi @goatboy, it seems that the value of "text" is a GeoJSON object, but its syntax is invalid. Is your posted document correct? I think the last two line should be as:

\":\"Feature\"}]}"
}

Assuming that my correction is correct, the attached workspace would be a solution: parse-embedded-geojson-example.fmw (FME 2016.1)

Many Thanks @takashi . it works perfectly. I now understand your use of multipule JsonFlatterers to get deeper in the data structure. Thanks Again

Steve

Reply