jed v0.5

Camilo MATAJIRA Avatar

Available: https://github.com/camilomatajira/jed

In this release, the main objective was to allow filters to be applied at any depth of the JSON, without having to specify the full path from the root.

Examples

In the following example, connectors.json contains around 1800 objects.
We can print the first connector using the expression 0,0p.

0,0 is an Array Range, but how does it work if the key at the root is "connectors" and not the array itself?

This is precisely what this release enables. Even though the Array Range does not match the root (connectors) (because it’s an object, and not an array), jed continues trying to match it recursively.

As a result, 0,0 can then be applied to the array under "connectors", and the filter is applied there.

cat connectors.json| jed -e '0,0p'
{
  "connectors": [
    {
      "account_types": [
        "checking"
      ],
      "account_usages": [],
      "auth_mechanism": "credentials",
      "available_auth_mechanisms": [
        "webauth",
        "credentials"
      ],
      "beta": true,
      "capabilities": [
        "bank",
        "twofarenew"
      ],
      "categories": [],
      "charged": true,
      "code": null,
      "color": "000064",
      "hidden": false,
      "id": 1325,
      "months_to_fetch": null,
      "name": "Aachener Bank eG",
      "products": [
        "bank"
      ],
      "restricted": false,
      "siret": null,
      "slug": "ABE",
      "stability": {
        "last_update": "2026-02-07 16:03:02",
        "status": "stable"
      },
      "sync_periodicity": null,
      "uuid": "c64a18a7-e071-487e-8318-f01c76896a29"
    }
  ]
}

Let’s say we are only interested in some attributes of the 0,0 object:

cat connectors.json| jed -e '0,0./name|uuid|auth/p'
{
  "connectors": [
    {
      "auth_mechanism": "credentials",
      "available_auth_mechanisms": [
        "webauth",
        "credentials"
      ],
      "name": "Aachener Bank eG",
      "uuid": "c64a18a7-e071-487e-8318-f01c76896a29"
    }
  ]
}

It is also possible to get /name|uuid|auth/ from all the 1800 connectors. Below we do this, but just print the first 2.

cat connectors.json| jed -e '/name|uuid|auth/p' | jed -e '0,1p'
{
  "connectors": [
    {
      "auth_mechanism": "credentials",
      "available_auth_mechanisms": [
        "webauth",
        "credentials"
      ],
      "name": "Aachener Bank eG",
      "uuid": "c64a18a7-e071-487e-8318-f01c76896a29"
    },
    {
      "auth_mechanism": "webauth",
      "available_auth_mechanisms": [
        "webauth"
      ],
      "name": "Abanca",
      "uuid": "31398607-7de7-4e11-a09e-6aa6076d1a87"
    }
  ]
}

The same applies for the other defined commands: d) for deletion; s) for value substitution, S) for key substitution.

What happens when the filters are chained?
If the filters are chained like below, the first filter marks the “anchor” or were the filter starts, and then the second filter must apply exactly at the next level of the JSON.

The example below prints the “values” that have a sucession of keys “stability” and then “starts with s”. Then for practicity I will print the first 4.

cat connectors.json| jed -e '/stability/./^s/p' | jed -e '0,3p'
{
  "connectors": [
    {
      "stability": {
        "status": "stable"
      }
    },
    {
      "stability": {
        "status": "stable"
      }
    },
    {
      "stability": {
        "status": "stable"
      }
    },
    {
      "stability": {
        "status": "stable"
      }
    }
  ]
}

Release notes:

# feat: Allow search/filter/anchor to start anywhere, not only at the beginning

    This aggregates the next commits:
    there is one intermeidate key that im losing
    test passed
    passes another test
    another tests passes
    another test passes
    solve bug
    now, the flexible print passes all the tests of the previous print
    delete passes!
    more tests pass
    more tests pass
    more tests pass
    everything passes
    new bug corrected
    more test pass, but added some prints
    another test passes
    More tests
    Add git ignore
    Add artificial root to tests,to simulate the new searching/anchoring feature
    Add more root to the tests
    remove legacy function
    Fix bug
    Update Readme
    Update readme

Tagged in :

Camilo MATAJIRA Avatar