Converting a multi nested JSON structure into a single array structure #267
-
DescriptionHow do I loop through a multi-nested JSON message and create a single array JSON object? The incoming JSON structure consists of multiple networks each network consists of multiple product types that consist of multiple products. IssueThe output is creating a response structure with additional array [] elements. Sample Request JSON shortened for simplicityExpected ResponseJSLT CodeActual Response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
Solved by changing my initial for to be [for (array(.networks))] and then did a flatten on the output. flatten(.products) Final JSTL code |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for updating with your solution! Using I think dealing with this type of nested structures is the biggest current weakness of JSLT, and it's one area I'd like to improve. That's going to take some time, though. |
Beta Was this translation helpful? Give feedback.
Solved by changing my initial for to be [for (array(.networks))] and then did a flatten on the output. flatten(.products)
Final JSTL code