Skip to main content
Solved

Nested JSON array to SQL table


ayraju
Contributor
Forum|alt.badge.img+1

I am using FME to extract API data and pull the JSON string into a SQL table. I am able to work with most of the tables but there are a couple of them that are nested and am having trouble getting to format properly.

I have attached how the results need to look and sample of the JSON results

I tried using JSON Fragmenter but i cannot get the results. Can someone advise the best way to get this.

Best answer by takashi

Hi @ayraju, basically you can use multiple JSONFragmenters to extract every content from each level in a nested JSON document.

However, according to the desired result table shown in your screenshot, the requirement is to extract keys of the JSON "fields" objects in the lowest level as attribute values. This isn't usual JSON flattening operation.

I would provide two different approaches to resolve the special requirement. One is using regular expression (StringSearcher), another is using XQuery (JSONiq extension) expression (XMLXQueryExtractor).

See these workspace examples. Both are created with FME 2018.1.0.2.

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

5 replies

mygis
Contributor
Forum|alt.badge.img+12
  • Contributor
  • October 4, 2018
Hi @ayraju can you share the link with us if it is public?

 


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • Best Answer
  • October 4, 2018

Hi @ayraju, basically you can use multiple JSONFragmenters to extract every content from each level in a nested JSON document.

However, according to the desired result table shown in your screenshot, the requirement is to extract keys of the JSON "fields" objects in the lowest level as attribute values. This isn't usual JSON flattening operation.

I would provide two different approaches to resolve the special requirement. One is using regular expression (StringSearcher), another is using XQuery (JSONiq extension) expression (XMLXQueryExtractor).

See these workspace examples. Both are created with FME 2018.1.0.2.


ayraju
Contributor
Forum|alt.badge.img+1
  • Author
  • Contributor
  • October 4, 2018
takashi wrote:

Hi @ayraju, basically you can use multiple JSONFragmenters to extract every content from each level in a nested JSON document.

However, according to the desired result table shown in your screenshot, the requirement is to extract keys of the JSON "fields" objects in the lowest level as attribute values. This isn't usual JSON flattening operation.

I would provide two different approaches to resolve the special requirement. One is using regular expression (StringSearcher), another is using XQuery (JSONiq extension) expression (XMLXQueryExtractor).

See these workspace examples. Both are created with FME 2018.1.0.2.

Wow, you are amazing. This is great. Thank you so much!

 

 


f.kemminje
Contributor
Forum|alt.badge.img+11
  • Contributor
  • May 28, 2019

@takashi I was just going thru the answers for my current Question, i got your answer . similar to this answer.

what if the json objects are dynamic. i mean if the geometry objects(geojson) and stored in nested arrays. and json query string is different for each geometry. in my case there are many geometries are stored inside json file. and not in one location, all are in different nested arrays.

How can we extract all the geometries from different nested arrays?


nampreetatsafe
Safer
Forum|alt.badge.img+12
f.kemminje wrote:

@takashi I was just going thru the answers for my current Question, i got your answer . similar to this answer.

what if the json objects are dynamic. i mean if the geometry objects(geojson) and stored in nested arrays. and json query string is different for each geometry. in my case there are many geometries are stored inside json file. and not in one location, all are in different nested arrays.

How can we extract all the geometries from different nested arrays?

FYI: An answer to @fkemminje's question was provided here:

 


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