Combining JSON objects in a Pentaho JavaScript JSON by matching keys to merge with an existing JSON document

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:

Answer №1

Don't worry about the constraints of Javascript in PDI. It utilizes the official Rhino OpenSource project, ensuring 100% ES6 compatibility.

Although JS's dynamic nature may cause a slight decrease in speed, the impact is unlikely to be noticeable unless you are dealing with an extremely high input rate of millions per minute.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

In React, is it typical to maintain identical values in both state and ref?

When working with my React app, I encountered a situation where I needed to access state values inside setTimeout() and setInterval(). However, due to closures being bound to their context once created, using state values in these functions would not refle ...

Convert a number to binary in JavaScript, but display the result as infinity

data = parseInt(num); bin =0; pow=1; var rem=0 ; while(data != 0){ rem = data % 2; data = data / 2; bin = rem * pow + bin; pow = pow *10; } document.write(bin); I encountered an issue with my JavaScript code. Even though the example should output 11011 ...

Incorporate Thymeleaf's HTML using the powerful JavaScript framework, jQuery

I am facing an issue where the Thymeleaf rendered HTML code is not being displayed by the Browser when I try to insert it using JavaScript. $('<span [[$ th:text#{some.property.key}]] id="counter" class="UI-modern"> </ ...

I'm having an issue with my NextJS timer where it doesn't stop and ends up going into negative numbers. Any

Here is the code snippet for my timer component. It fetches the 'createdAt' prop from the database and functions correctly. However, I have encountered an issue where the timer does not stop at 0 but continues running indefinitely. I attempted to ...

Creating dictionary data in JSON format using Python is a simple process

As a newcomer to Python, I am currently grappling with understanding how to work with dictionaries operations. Here is the data that I have: [{'mesure':'10', 'name': 'mumbai', 'age': '15', &apos ...

chart for visualizing two rows with matching IDs and dates

I have been attempting to accomplish the following two scenarios: 1) When both ID and dates are the same in the chart, but the descriptions differ, I want to display them on separate lines. 2) If there is not enough room to show the row label, I would li ...

Navigating to an Element in React's Document Object Model

Using React 16.4, I am faced with the need to scroll to a specific DOM element within the application. Since refs are deprecated in React, I am on a quest to find the most elegant solution for this problem. However, I find it challenging to come up with a ...

What is the best way to trigger a controller action when the datepicker's value changes?

Hello, I have a custom datepicker and I am trying to perform a calculation when the year is changed. The code provided below does not seem to work on onchange. I also attempted using the onchange attribute and calling a JavaScript function like this oncha ...

Utilizing sed for updating the value of a specific key within a JSON object

What is my objective? If you have a file containing JSON events, the goal is to identify specific events using keywords and then update the value of a key within that event to an empty string. This task needs to be accomplished using sed (due to Splunk fo ...

Loading JSON data into an ExtJS combo box

I am having JSON data: {"total":100, "category": [Village, City, School, HighSchool]} for an ExtJS combobox: reader: new Ext.data.JsonReader({ root: 'category'}, [{name: 'category'}]) The data is not loading in the combobox. When I ...

Conceal a division based on its numerical position

I'm having trouble figuring out how to hide multiple divs based on an index that I receive. The code snippet below hides only the first div with the id "medicalCard", but there could be more than one div with this id. document.getElementById("medical ...

How come I am not receiving any replies when using cUrl along with a class?

When I write my code without a class, it works perfectly and returns a "SUCCESS" response. However, when I encapsulate it within a class, it doesn't seem to work. Here is the full code: class THBS_API { private const call_url = "https://xxxxxxx ...

Script on Google Sheets fails to update with every event trigger

I came across a JSON import script while exploring. /** * Retrieves all the rows in the active spreadsheet that contain data and logs the * values for each row. * For more information on using the Spreadsheet API, see * https://developers.google.com/a ...

Can a JavaScript function spontaneously run without being called upon?

<a onclick="determineCountry(data)" class="installbtn">Install</a> My goal is to have the user redirected to one of three sites based on their location when they click the button above. However, there seems to be an issue with the script below ...

Statistics Sweden SCB API call was made, but unfortunately, no data was retrieved

I am having trouble accessing the actual values of the data in my table, as all I can see is the dates in the JSON output generated. The specific link I am using is: "http://api.scb.se/OV0104/v1/doris/en/ssd/START/FM/FM5001/FM5001A/FM5001SDDSPM" ...

An effective method to utilize .map and .reduce for object manipulation resulting in a newly modified map

Here's an example of what the object looks like: informations = { addresses: { 0: {phone: 0}, 1: {phone: 1}, 2: {phone: 2}, 3: {phone: 3}, 4: {phone: 4}, 5: {phone: 5}, }, names: { 0 ...

Is there a way to customize the ripple effect color on a Button?

As I'm exploring the API (v3.9.2), I have noticed a reference to TouchRippleProps for ButtonBase on https://material-ui.com/api/button-base/ The code for my button is as follows: <Button variant="text" size={"large"} ...

jQuery blueimp File Uploader: Transferring multiple files to the server on Internet Explorer

After customizing the demo for my Rails application, I encountered an issue with the plugin in Internet Explorer. While it works smoothly on Chrome and Firefox, in IE (all versions) it fails to upload all but one file when multiple files are selected, and ...

Incorporating a background image into a card component using props

I attempted to add a background image to the card component through props, but the image failed to display on the card. I didn't encounter any errors, and I'm unsure what mistake I might be making. Any suggestions or alternative solutions would b ...

Verify the Absence of an Internet Connection Through a Popup on a Windows 10 Application Developed in Javascript

Hey there, I've been browsing the web but can't seem to find a comprehensive tutorial on how to write a code that displays an error message when there is no internet connection. I'm currently using Visual Studio to develop a Windows 10 App w ...