I managed to generate a new json from the original one getting the info I need but now I see there's some missing data.
Each project group has an id, lat-lon info and an array with data for every project inside the group.
I generate a new json with a feature for every project but need to also add a feature for every project group without projects in it.
This is what I have:
t
let $doc := fme:get-json-attribute("_response_body")
for $i in (1 to jn:size($doc))
let $id := $doc($i)("id")
let $lat := $doc($i)("lat")
let $lon := $doc($i)("lng")
let $proj := $doc($i)("projects")
for $j in (1 to jn:size($proj))
return
{|
{"id" : $id},
{"lat" : $lat},
{"lon" : $lon},
{"proj_name" : $proj($j)("name")}
|}
]
I've tried to nest an If statement to check when $proj is empty but it throws an error.