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

jsonpath arithmetic operators support #2909

Open
NamanGajjar26 opened this issue Oct 20, 2023 · 1 comment
Open

jsonpath arithmetic operators support #2909

NamanGajjar26 opened this issue Oct 20, 2023 · 1 comment

Comments

@NamanGajjar26
Copy link

NamanGajjar26 commented Oct 20, 2023

"$.order[ * ].Product[ * ].price" * "$.order[ * ].Product[ * ].qut"

json path in multiply two field like upper example
any solution for this

@elgonzo
Copy link

elgonzo commented Oct 20, 2023

I am just a user of Newtonsoft.Json (like yourself) and not associated with the project nor its author/maintainer.

any solution for this

No, not with the JsonPath support as provided by Newtonsoft.Json as far as i know.
You either have to do the arithmetic operations in code after obtaining the json elements of interest, or switch to an alternate json library/processor that supports arithmetic operations in JsonPath expressions.

A possible alternative might perhaps be json-everything -- in particular its JsonPath.Net package, which according to its documentation supports arithmetic operations. Note that json-everything is dependent on System.Text.Json. Also note that i have no noteworthy experience with json-everything, so i am not really able to give advice or opinions about it (and not withstanding the fact that this here is the issue tracker of Newtonsoft.Json and not a json-everything discussion forum). If json-everything isn't suitable for you, i am afraid you will have to seek out an alternative yourself...

P.S.: Keep in mind that arithmetic operations are not defined by the JsonPath specification (https://www.ietf.org/archive/id/draft-ietf-jsonpath-base-21.txt). Therefore, arithmetic operations constitute non-standard extensions of the JsonPath expression syntax. In other words, do not expect nor assume a common and well-defined way of how arithmetic operations would be realized across different JsonPath parser implementations.

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

2 participants