Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do we have function to reconstruct from parsed object? #55

Open
Thaina opened this issue Oct 2, 2019 · 0 comments
Open

Do we have function to reconstruct from parsed object? #55

Thaina opened this issue Oct 2, 2019 · 0 comments

Comments

@Thaina
Copy link

Thaina commented Oct 2, 2019

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`

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant