Skip to main content
Question

Decode JSON

  • May 2, 2018
  • 2 replies
  • 12 views

peteralstorp
Contributor
Forum|alt.badge.img+7

Hello, JSON-lovers!

We've been trying to extract the attributes from this response body but however we do it seems like we need to input the attributes we need manually. This can't be true. We would like to get all the attributes no matter what. We're no JSON-specialist as you can probably guess... Is there an easy way to do this?

Response body:

[{"ObjectId":507,"ComponentId":3,"Metadata":{"KomponentNamn":"AB+56232=270XO001","Lansbokstav":"AB","Objekt":"56","ObjektId":507,"KomponentId":3,"Area":"2","Placering":"32","System":"27","Underniv":"0","Beteckning":"XO","Nr":"001","Underlitt":"","Beskrivning":"Övrigt konstruktionselement, Polygonpunkt","Entreprenor":"","Leverantor":"Ab Tolle","Tillverkare":"","X":6570455.3729,"Y":143139.124,"Z":0.0,"SlutX":0.0,"SlutY":0.0,"SlutZ":0.0,"Grupp":"Admin","Kommun":null,"Vagnr":null,"PlaceringVagomr":null,"Rumsbeteckning":"","Artikelnr":"","Markning":"","GPDOmrade":null,"Entreprenad":"","Driftomrade":"","KomponentStatus":0,"KompStatus":"Ny/reserverad","Valfri1":"","Valfri2":"","Valfri3":"","Valfri4":"","Valfri5":"","XTM":6571368.807,"YTM":664217.876,"ZTM":0.0,"SlutXTM":0.0,"SlutYTM":0.0,"SlutZTM":0.0,"OverordnadELKRAFT":null,"OverordnadTEKNIK":null,"OverordnadSTYR":null},"Documents":[...TRUNCATED...],"Attributes":[]}]

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

daveatsafe
Safer
Forum|alt.badge.img+19
  • Safer
  • 1637 replies
  • May 2, 2018

Hi @peteralstorp,

The JSONFragmenter transformer can break up the JSON into features, and extract the feature attributes for you, if you set Flatten Query Result into Attributes to 'Yes'.

The transformer does not automatically expose the extracted attributes for you, since the content of the JSON is not known until the workspace is run. You will need to expose the attributes you need to work with (ie. X and Y) manually.

The rest of the attributes can automatically be included on the writer output, if you use dynamic writing, and supply a schema on the features. The FME Hub transformer SchemaSetter will create the schema for you.

Most writers do not support lists in their schemas, so you will need to explode the Documents{} list on your features before sending to the SchemaSetter, to create a separate feature for each entry in the Document list.


peteralstorp
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • 91 replies
  • May 2, 2018

Sounds perfect, try it tomorrow! Thanks a lot!