5 ms·
Playing with `jp` a bit, I still like it, but it's very frustrating to do updates in place. For example, I wanted to write a simple expression to delete output
by ben509 7y ago
Playing with `jp` a bit, I still like it, but it's very frustrating to do updates in place.
For example, I wanted to write a simple expression to delete outputs from an ipython notebook.
{
"cells": [{
"stuff": "blah blah",
"outputs": ["crap", "to", "delete"]
}], "other stuff": "blah blah"
}
The simplest expression I could come up with was:
merge(@, {
"cells": map(
&merge(@, {"outputs": `[]`}),
cells[]
)
})
And that's verbose because you're reconstructing the structure.
In fairness, it's impressive that the language can express it at all, given it's a query language.
Maybe the real answer is to denote a subset of JMESPath that is guaranteed to return assignable nodes, that is only selects, slices, filters, etc. Then you run the query and perform assignments against those.