Skip to main content
Solved

Json attributes extraction


boubcher
Contributor
Forum|alt.badge.img+11

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

Best answer by daveatsafe

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

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

5 replies

geosander
Forum|alt.badge.img+7
  • July 27, 2018

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!


danilo_fme
Evangelist
Forum|alt.badge.img+44
  • Evangelist
  • July 27, 2018

Hi @boubcher

I simulated here in my Workspace with some transformers:

Results in FME Data Inspector:

Attached the Workspace - workspace-json.fmw

Thanks,

Danilo


daveatsafe
Safer
Forum|alt.badge.img+19
  • Safer
  • Best Answer
  • July 27, 2018

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


boubcher
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • July 28, 2018
daveatsafe wrote:

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

 


takashi
Influencer
  • July 29, 2018

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


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