JSON Input and JSON Output Component in Pentaho

Today i will discuss about the json input and json output component in Pentaho.  So , in first scenario, i will load the text file to json output . Below is the image for the same.

Here, i am using order_Details.txt as input file which has data related to orders. In JSON output component, few things should be kept in mind .

  1. Json bloc name  :- Name of the bloc, it should be as per the input file. so , in my cases i have kept “ORDER” as Json bloc name.
  2. Nr rows in a bloc :- In this, mention the number of rows for the json output. For example, if i will mention 10 , that means in json output , data will come for 10 input rows. As i want to take all the input rows to json output, i have kept this field as BLANK.  
  3. In the fields section, get the field names which is coming from the source.

Below is the image for the same.

Post execution of the code, this is how the json output looks like.

Now, We will consume this output file using JSON input component and load into text file.Below is the image for the same.

The interesting part in JSON input component is how to read the fields of json file. As i have already added the output file image above, so we have fields like date,year,month,price and order_no.

If i want to read date field from JSON file , then it will like “$.ORDER[*].date”. See the below image for the same.

Post execution of the code, the output file will get generated. The entire code is checked in to git.

https://github.com/Karan-Arora-13/technicalstuff

Related posts