display-medicalRead JSON

Read JSON objects.

circle-exclamation

Workshop - Read JSON

JSON Input

circle-info

Workshop files

Download the following files.

Keep the filenames unchanged.

Save them in your workshop folder.

file-download
17KB

JSON input
circle-info

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:

circle-info

status can be Delivered or Returned.


circle-info

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.

circle-info
  1. Drag JSON Input onto the canvas.

  2. Open the step.

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

circle-info

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
circle-info

Need help writing JSONPath? Use a tester like: https://jsonpath.com/arrow-up-right


Troubleshooting

chevron-rightNo rows returnedhashtag

Check the Loop path first. For this file, it must point to the array:

If the JSON structure changes, update the loop path.

chevron-rightFields are nullhashtag

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

chevron-rightWrong data typeshashtag

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

Example: keep status as String.

Last updated

Was this helpful?