News for hackers. Stuff that matters.
Re:Jolt – JSON to JSON transformation by lobster_johnson on Thursday November 24, 2016 @02:56PM (#13032391)
Related/shameless plug: We've been working on a reimagining of JSONPath [1] which we hope will be useful to other people.

Unfortunately, it's not public yet — though we have working libraries in JavaScript and Go (a heavily modified fork of Kubernetes' JSONPath code) we intend to release — mostly because we want to publish a proper spec. In fact, we're looking for a good name for it, as we feel that releasing "JSONPath 2.0" would be a little presumptious. I was thinking something like JSONMatch. If there's sufficient interest I could prioritize it (email me!).

Our own version of JSONPath is intended for both searching and patching documents in general. A simple search would be something like:

    friends[name == 'bob'].id
or

    shoppingItems[1:3][description, id]
We use this to declaratively extract data from documents, but also change it. The patching support lets you do things like:

    match(document, "..[role == 'owner'].role")
      .set('admin');
This will set "role". It gets rather magical and beautiful when you have multiple paths that involve unions, subindexed arrays and constraints.

We also have a separate patch notation, expressed in JSON, to declaratively transform documents. It uses these JSONPaths to select and set values. We might write a spec for that, too, although I'm not sure the utility outside our app is that great.

[1] http://goessner.net/articles/JsonPath/

There are no comments on this comment yet.