Read JSON

Read JSON objects.

Workshop - Read JSON

JSON Input

Workshop files

Download the following files.

Keep the filenames unchanged.

Save them in your workshop folder.

17KB
Open

JSON input

Create a new transformation

Use any of these options to open a new transformation tab:

  • Select File > New > Transformation

  • Use Ctrl+N (Windows/Linux) or Cmd+N (macOS)


  1. Open jsonfile.js in 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.

  1. Start Pentaho Data Integration.

  1. Drag JSON Input onto the canvas.

  2. Open the step.

  3. On the File tab, select your jsonfile.js.

Save your transformation near jsonfile.js. Then use a portable path.

Example:

  1. Set Loop path to:

  1. Open the Fields tab.

  2. Select Get Fields.

  3. Verify these field paths and types:

  • productline (String)

  • customer (String)

  • status (String)

  • date (String)

  • value (Number)

JSON input - file
JSON input - fields

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.

Fields are null

Confirm field paths match the JSON keys. If you loop over order[*], use productline, not $.document.order.productline.

Wrong data types

Use Get Fields as a starting point. Then set types explicitly.

Example: keep status as String.

Last updated

Was this helpful?