Skip to main content
Question

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

  • November 23, 2020
  • 3 replies
  • 39 views

geo-x
Participant
Forum|alt.badge.img
  • Participant

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.

3 replies

geo-x
Participant
Forum|alt.badge.img
  • Author
  • Participant
  • 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+31
  • Influencer
  • November 24, 2020

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


geo-x
Participant
Forum|alt.badge.img
  • Author
  • Participant
  • November 24, 2020

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


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