-
Notifications
You must be signed in to change notification settings - Fork 221
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
lost with an expression #716
Comments
It's almost impossible to know what the expression is meant to do without knowing your input JSON. Try using the exerciser and saving a link. It will capture your input and your expression. But there are a few problems I could point out:
You need to think of jsonata expression not as a procedural programming language, but a sort of select statements for JSON data. So, here's a stab at the approach I would take, again without understanding exactly what you want to do or what the input JSON is:
|
Thanks a lot for your time, it's hard for me to understand right now the goal or how it works jsonata, I m dev and this is not a traditional dev language. It's very very fast, this for sure. Finally, with the help of one mate I could afford it: (
) I have an array of products, every product has an array of agreements, I ve to sum the totalAmount of the agreements (only of offerType="OP") once. If there are 5 agreements with id X I only ve to sum once the totalAmount, not 5. Sorry if my explanation is not very well, my english... thanks a lot! |
JSONata is an expression syntax, like XPath, JMESPath, jq filters, JEXL or SPeL. These all use declarative expressions. Even though JSONata has functions, the $map function is not used as much since it's more idiomatic to use the path mapping operator
Back to your scenario, it would be really helpful for you to provide an exerciser link instead of describing the structure of the input. For example, here is my best guess at your input based on your description. Exerciser Link. Make changes, and use this icon to save your version, and share it here. |
Hi, I m getting crazy with this jsonata expression, I don't know why the $append seems not working, the $uniqueIds is always empty at the output indistinctly the lookup value (true, false..), the total variable the same, some idea how to continue? I only need those values updated inside the $map.
(
$uniqueIds := [];
$total := 0;
)
some clue? thanks
The text was updated successfully, but these errors were encountered: