Skip to content

JSON: Filter

Filters JSON data based on a key-value condition. Accepts a list (array) of objects and returns only those objects whose specified key matches the given value according to the selected mode (equals, contains, starts_with, ends_with). If the input is a JSON string, it will be parsed before filtering.
Preview

Usage

Use this node when you need to narrow down an array of JSON objects to only those matching a simple key-value rule. Typical workflow: load or produce JSON data (often an array of objects), then filter it by a specific field and comparison mode before passing the result to subsequent processing nodes.

Inputs

FieldRequiredTypeDescriptionExample
json_dataTrueWILDCARDThe JSON data to filter. Should be an array (list) of objects. If provided as a string, it will be parsed.[{"status":"active","id":1},{"status":"inactive","id":2}]
filter_keyTrueSTRINGThe object key to evaluate for each item in the array.status
filter_valueTrueWILDCARDThe value to compare against for the chosen key. Used differently depending on filter_mode.active
filter_modeTrueENUM: equals\|contains\|starts_with\|ends_withHow to compare the item's value for filter_key with filter_value. equals uses exact equality; contains, starts_with, and ends_with perform string-based checks.equals

Outputs

FieldTypeDescriptionExample
filtered_dataWILDCARDThe filtered JSON data. Typically a list of objects matching the filter condition. If filtering is not applicable, the original data is returned.[{"status":"active","id":1}]

Important Notes

  • Input type: The node expects json_data to be a list (array) of objects. If it's not a list, the data is returned unchanged.
  • String parsing: If json_data is a string, it will be parsed as JSON before filtering.
  • Key requirement: If filter_key is empty, no filtering is done and the original data is returned.
  • Missing keys: Objects without the specified filter_key are ignored (not included in the result).
  • Comparison behavior: equals uses exact equality without converting types; contains, starts_with, and ends_with compare using string representations of values.
  • Error handling: On parsing or runtime errors, the node logs the error and returns the original input unmodified.

Troubleshooting

  • No filtering occurs: Ensure json_data is an array of objects and filter_key is not empty.
  • Unexpected matches with 'equals': Check for type mismatches (e.g., number vs string). equals does not coerce types.
  • Contains/starts/ends not matching: These modes are string-based and case-sensitive. Convert values to a consistent case beforehand if needed.
  • Got original data back: This happens if input wasn't a list, filter_key was empty, or an internal error occurred. Validate your input format.
  • JSON string input fails: Verify the JSON string is valid and represents an array of objects.