“Filter JSON by fields” allows you to filter out unwanted fields in a JSON dictionary.

On this page, we will introduce the Tool step to “Filter JSON by fields”.

How to use “Filter JSON by fields” step

Add the component

Add the “Filter JSON by fields” step to your Tool (check how to get started with creating a tool).

Object to filter

A “Filter JSON by fields” step requires a JSON object as an input. This object can be entered within the step. However, it is often more practical to fetch the value from an input component (e.g. JSON input) or another step output (e.g. String to JSON). Use {{variable name}} to provide the data to the “Filter JSON by fields” step.

Fields to keep

This is to specify which fields (i.e. dictionary keys in the JSON input) must be kept. Note that the field names must be typed EXACTLY the same as what was provided in the input.

Follow the links below for more information about

Access the step output

The output is a dictionary with a key filtered. Below you can see samples where the default name assigned to the step json_filtered is used. Note that a step name is different from the step title. Step titles can be found on the top left of steps. A step name is shown on the bottom left, in smaller font and highlighted green.

json_filtered.filtered

Common errors

Unsupported input

An error similar to the one noted below indicates that the provided input is not a valid JSON object.

Studio transformation object_key_filter input validation error: must be object {"type":"object"} /haystack