My goal is to construct a Json document by breaking it down into smaller pieces, with each piece containing the necessary keys to insert the smaller Json bits into the correct json structure. As I am relatively new to JavaScript and still in the process of learning it from scratch, I will do my best to explain the issue and my desired outcome.
The problem arises as most Pentaho/Json resources I come across provide hardcoded JavaScript solutions for building pre-formed Json structures, which have a fixed number of fields. What I need is a way to dynamically insert/create information into a Json Structure, including nested structures.
Initially, the flat Json structure can be easily built using the Json output Step in Pentaho since it outputs built Json objects that can potentially be dynamically created and concatenated (though I'm unsure if this functionality exists). Once the flat part is completed, the challenge lies in assembling the other objects within the correct structure, some being simple objects while others are arrays of objects (nested part).
I require verification from someone well-versed in this area whether it is feasible to achieve this through Pentaho JavaScript, or if the only approach would involve building hardcoded structures. I will demonstrate below what I envision:
This serves as an example of the Flat JSON: