We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hello. Is there a way (out of the box) to use a global variable in the iteration operators like "some" or another way to create a similar rule?
I need to do this.
Example: Note: global_var does not exist. Only for demo purposes.
Rule: { "some": [ { "var": "x" }, { "in": [ { "var" : "" }, { "global_var": "y" }] } ] }
Data: { "x": [1, 2, 3, 4], "y": [0, 1, 5] }
First iteration: { "some": [ [1, 2, 3, 4], { "in": [ 1, [0, 1, 5] ] } ] }
Second iteration: { "some": [ [1, 2, 3, 4], { "in": [ 2, [0, 1, 5] ] } ] }
...
ATM it will work like this (i iteration count) { "some": [ { "var": "x" }, { "in": [ { "var" : "" }, { "var": "y" }] } ] }
{ "some": [ { "var": "x" }, { "in": [ x[i], x[i].y" ] } ] }
The text was updated successfully, but these errors were encountered:
I think I ran into the same issue:
const data = { numbers: [1, 2, 3] } const singleRule = { in: [1, { var: 'numbers' }] } expect(jsonLogic.apply(singleRule, data)).toEqual(true) // OK const arrayRule = { some: [[1], { in: [{ var: '' }, { var: 'numbers' }] }] } expect(jsonLogic.apply(arrayRule, data)).toEqual(true) // Fails :(
Ended up with custom operators, but would love to see it somehow work out of the box.
Sorry, something went wrong.
This is the root of the problems in #61, #48, #134, #135, #124, as well.
No branches or pull requests
Hello.
Is there a way (out of the box) to use a global variable in the iteration operators like "some" or another way to create a similar rule?
I need to do this.
Example:
Note: global_var does not exist. Only for demo purposes.
Rule:
{
"some": [
{ "var": "x" },
{ "in": [ { "var" : "" }, { "global_var": "y" }] }
]
}
Data:
{
"x": [1, 2, 3, 4],
"y": [0, 1, 5]
}
First iteration:
{
"some": [
[1, 2, 3, 4],
{ "in": [ 1, [0, 1, 5] ] }
]
}
Second iteration:
{
"some": [
[1, 2, 3, 4],
{ "in": [ 2, [0, 1, 5] ] }
]
}
...
ATM it will work like this (i iteration count)
{
"some": [
{ "var": "x" },
{ "in": [ { "var" : "" }, { "var": "y" }] }
]
}
{
"some": [
{ "var": "x" },
{ "in": [ x[i], x[i].y" ] }
]
}
The text was updated successfully, but these errors were encountered: