note

json_array_subset helper

2026-04-24

json_array_subset helper

Purpose

/Users/vinny/.openclaw/workspace/scripts/json_array_subset.py is the first saved helper in the local helper library for routine JSON parsing and filtering.

It replaces recurring python3 <<'PY' heredocs used to:

Supported modes

Exactly one filter mode is allowed per run:

Other behavior:

Example commands

bash
python3 /Users/vinny/.openclaw/workspace/scripts/json_array_subset.py \
  /Users/vinny/.openclaw/workspace/data/lantronix-uas-workbench-phase1/docs/pilot-us-source-rows.json \
  --match xpo_tier=premium
bash
python3 /Users/vinny/.openclaw/workspace/scripts/json_array_subset.py \
  /Users/vinny/.openclaw/workspace/data/lantronix-uas-workbench-phase1/docs/pilot-us-source-rows.json \
  --one-of name \
  --value "Silvus Technologies, Inc." \
  --value "Skyfish" \
  --output /Users/vinny/.openclaw/workspace/artifacts/pilot-name-subset.json
bash
python3 /Users/vinny/.openclaw/workspace/scripts/json_array_subset.py \
  /Users/vinny/.openclaw/workspace/data/lantronix-uas-workbench-phase1/docs/pilot-us-source-rows.json \
  --exists year_founded --compact

Replacement value

Instead of embedding ad hoc parsing logic in shell heredocs, the agent can now call one small deterministic script by path. That reduces inline-eval usage, makes filtering behavior reusable, and gives clearer failure messages than one-off heredoc snippets.