jmespath / jmespath/jmespath.js

Do we have function to reconstruct from parsed object?

Open
#55 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
847
Forks
101
PR merge metrics
No merged PRs in 30d

Description

While we could parse the expression into object. I wish that we should be able to also reconstruct the object that was parsed back to expression. So I could write editor and perform some editing, or just partially reconstruct the subexpression into string text

Suppose I have expression `` propertyA.valueA > `10` ``

```jmespath
var expression0 = "propertyA.valueA > `10`";
var parsed = jmespath.parse(expression0);

parsed.name = parsed.name == "GT" ? "LT" : "GT";

var expression1 = jmespath.reconstruct(parsed); // became "propertyA.valueA < `10`";

var subExpression = jmespath.reconstruct(parsed.children[0]); // get "propertyA.valueA"
parsed.children[0].name = subExpression == "propertyA.valueA" ? "propertyB.valueB" : "propertyA.valueA";

var expression2 = jmespath.reconstruct(parsed); // became "propertyB.valueB < `10`";
```

Is it already possible? If not I would like to have this be feature request

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.