Read JSON
Read JSON objects.
Workshop - Read JSON
Parse a JSON file into rows. Use JSON Input.
What you’ll do
Read a JSON file from disk.
Set a loop path for an array.
Extract fields with JSONPath.
Use Get Fields to infer metadata.
Preview rows and validate types.
Prerequisites: Basic transformations. Basic JSON (objects, arrays). PDI installed.
Estimated time: 15 minutes
Workshop files
Download the following files.
Keep the filenames unchanged.
Save them in your workshop folder.

Create a new transformation
Use any of these options to open a new transformation tab:
Select File > New > Transformation
Use
Ctrl+N(Windows/Linux) orCmd+N(macOS)
Open
jsonfile.jsin an editor. You will extract fields from this array:
status can be Delivered or Returned.
JSON Input
JSON Input reads JSON and outputs rows.
You set one loop path. It outputs one row per loop element.
Start Pentaho Data Integration.
Drag JSON Input onto the canvas.
Open the step.
On the File tab, select your
jsonfile.js.
Save your transformation near jsonfile.js. Then use a portable path.
Example:
Set Loop path to:
Open the Fields tab.
Select Get Fields.
Verify these field paths and types:
productline(String)customer(String)status(String)date(String)value(Number)


Need help writing JSONPath? Use a tester like: https://jsonpath.com/
Troubleshooting
No rows returned
Check the Loop path first. For this file, it must point to the array:
If the JSON structure changes, update the loop path.
Last updated
Was this helpful?

