Skip to main content
Question

How can I build a json from list with sub sub sub object ?

  • November 23, 2020
  • 3 replies
  • 59 views

geo-x
Supporter
Forum|alt.badge.img+6

Dear FME community.

 

I'm trying to extract, from a json object, the json arrays.

My object looks like :

aAs you can see, I've multiple sub objects and I want to extract this parts :

aaIn this case, I tried to use the transformer jsontemplater but I was stopped by the loop in the json for sub sub object.

In this part I do this :

eeeBut maybe it' not the best method, that's why I need help.

Do you see how can I do this ?

Thank you very much.

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.

3 replies

geo-x
Supporter
Forum|alt.badge.img+6
  • Author
  • Supporter
  • November 24, 2020

In fact, I try to make a loop in a loop in a loop ...

I found this solution :

{
"Attributes":[  for $Age at $pos in fme:get-list-attribute("_list{}.Age")
     let $Date := fme:get-attribute(concat("_list{",$pos - 1,"}.Date"))
     return {"Date":$Date, "Age": $Age}]
}

that work for 1 sub object but for multiple sub object ??

{
"Attributes":[ 
for $Age at $pos in fme:get-list-attribute("_list{}.Age")
let $Date := fme:get-attribute(concat("_list{",$pos - 1,"}.Date"))
return {
"Date":$Date, 
"Age": $Age,
"Sub Attributes":[ 
for $SubAge at $Subpos in fme:get-list-attribute("_list{}.SubAge")
let $SubDate := fme:get-attribute(concat("_list{",$pos - 1,"}.SubDate"))
return {
"SubDate":$SubDate, 
"SubAge": $SubAge,
"SubSubAttributes":[ 
for $SubSubAge at $SubSubpos in fme:get-list-attribute("_list{}.SubSubAge")
let $SubSubDate := fme:get-attribute(concat("_list{",$pos - 1,"}.SubSubDate"))
return {
"SubSubDate":$SubSubDate, 
"SubSubAge": $SubSubAge,
}
]
}
]
}
]
}

 

 


ebygomm
Influencer
Forum|alt.badge.img+46
  • Influencer
  • November 24, 2020

Can you share your sample json as text rather than a screenshot?


geo-x
Supporter
Forum|alt.badge.img+6
  • Author
  • Supporter
  • November 24, 2020

Thanks for your reply @ebygomm​ I've data extract join in this post :-)