Skip to main content

I am having trouble extracting all the information from a JSON. I have a JSON (see attached) with multiple addresses on the same level. When I use the JSON Flattener or the JSON fragmenter I only get the first address.

The JSON in the attachment contains for example a JSONFeature addresses with the subfeature type which can be "vestigingsadres" or "correspondentieadres".

This is just an example, same JSON I work with contain multiple addresses. And on forehand I do not know how many.

How can I extract this information?

Hi @stefanh, The JSON schema contains a list object called "items" and each "items" object contains sub list object called "addresses". If you apply the JSONFlattener to the document, the resulting feature will have this nested list attribute.

items{}.addresses{}.bagId
items{}.addresses{}.city
items{}.addresses{}.country
... and so on.

You can extract required elements from the list. Check the content of the list with Feature Information window in FME Data Inspector, after flattening the document with the JSONFlattenere.


Hi @stefanh, The JSON schema contains a list object called "items" and each "items" object contains sub list object called "addresses". If you apply the JSONFlattener to the document, the resulting feature will have this nested list attribute.

items{}.addresses{}.bagId
items{}.addresses{}.city
items{}.addresses{}.country
... and so on.

You can extract required elements from the list. Check the content of the list with Feature Information window in FME Data Inspector, after flattening the document with the JSONFlattenere.

Hi @takashi thanks for the quick response. I implemented your suggestion and this works. See screenshot. 

 

However I do not always know how many addresses the JSON-document contains. Is there a way to extract all the address information without knowing the number of sub list objects?. 

 

So a more uniform way, instead of defining "addresses{0}.type" and "addresses{1}.type"

 

 

Hope this is possible

 

 

 

 


Hi @takashi thanks for the quick response. I implemented your suggestion and this works. See screenshot.

 

However I do not always know how many addresses the JSON-document contains. Is there a way to extract all the address information without knowing the number of sub list objects?.

 

So a more uniform way, instead of defining "addresses{0}.type" and "addresses{1}.type"

 

 

Hope this is possible

 

 

 

 

Maybe this Q and A is relevant to you, stefanh?

 

 

https://knowledge.safe.com/questions/69497/decode-json.html?childToView=69498

 

 

 


Hi @takashi thanks for the quick response. I implemented your suggestion and this works. See screenshot.

 

However I do not always know how many addresses the JSON-document contains. Is there a way to extract all the address information without knowing the number of sub list objects?.

 

So a more uniform way, instead of defining "addresses{0}.type" and "addresses{1}.type"

 

 

Hope this is possible

 

 

 

 

Hoi @stefanh,

 

Have a look at the List Exploder transformer, to convert list elements into features.

 

Hope this helps,

 

Itay