Skip to main content

How to extract the attribute from the Json file , with the content

I trauied all Json transformer but did give me what I am looking for

Json content

[{"code":"EPSG:4326"},{"x":"41.86306379123165","y":"19.05070466974152"},{"x":"41.86136208513543","y":"19.048743553071773"},{"x":"41.8575815484205","y":"19.05212744890353"},{"x":"41.86306379123165","y":"19.05070466974152"}]

we want this

If that is what you need, and you have write access to the JSON document, you might consider restructuring your JSON, because this reeks of bad data modeling (sorry). It will be a whole lot easier to read/transform!


Hi @boubcher

I simulated here in my Workspace with some transformers:

Results in FME Data Inspector:

Attached the Workspace - workspace-json.fmw

Thanks,

Danilo


Hi @boubcher,

You can use the JSONFragmenter to break up the JSON records, and flatten into feature attributes. Then you can separate the code record and apply it the following locations using a VariableSetter and VariableRetriever.

flattenjson.fmw


Hi @boubcher,

You can use the JSONFragmenter to break up the JSON records, and flatten into feature attributes. Then you can separate the code record and apply it the following locations using a VariableSetter and VariableRetriever.

flattenjson.fmw

the variable setter and retriever transformer are great

 

I can used them in many cases I have

 

Thanks

 


Another thought. This workflow reconstructs the JSON document then fragments/flattens that. 

Template Expression in the JSONTemplater: Assuming the the input feature has an attribute called "_json_doc" which stores the original JSON document.

 
    let $m := fme:get-json-attribute('_json_doc')
    for $i in (2 to jn:size($m))
    return { "code" : $m(1)("code"), "x" : $m($i)("x"), "y" : $m($i)("y") }
]

0684Q00000ArL1aQAF.png


Reply