Comments (4)
Hi @Gigaclank ,
I've copied your code and your first 2 examples returned the expected 3. The last example does not work, because $.*.*.val
is an array that contains ´3´
Which version do you use?
from gval.
Hi @Gigaclank ,
I've copied your code and your first 2 examples returned the expected 3. The last example does not work, because
$.*.*.val
is an array that contains ´3´Which version do you use?
I am using the latest version of gval and jsonpath with golang 1.12.6 in a docker container.
from gval.
i have found a work around which is to in my evaluation rule change it from:
$.*.*.val == 3
to
$.*.*.val == [3]
its a workaround but is not particularly user friendly whenever i am allowing my users to create the rule from a UI.
from gval.
You could use something like
value, err := gval.Evaluate("$.*.*.val == 3", v, jsonpath.Language(), gval.InfixOperator("==", func(a, b interface{}) (interface{}, error) {
aa, ok := a.([]interface{})
if !ok {
return reflect.DeepEqual(a, b), nil
}
for _, x := range aa {
if reflect.DeepEqual(x, b) {
return true, nil
}
}
return false, nil
}))
in order to scale up the equals operator to multiple values.
from gval.
Related Issues (20)
- how to visit json node whose key with special characters,like $
- Question on thread safety of concurrent evaluations HOT 2
- NewEvaluableWithContext purpose
- Passing a context to the custom functions HOT 1
- feat request: null safe operator
- feature request: add metadata in evaluable HOT 5
- functions inside expression are evaluated in coroutine and on panic are not recovered thus crashing whole application
- How to get rendered expressions HOT 4
- Publish new version for DecimalArithmetic HOT 2
- Allow variables to overload functoins HOT 2
- Allow dashes in identfiers HOT 1
- I need to check string contains using gval expression
- Feature Request: high order functions (collection)
- Evaluating strings with backslashes raises parsing errors HOT 1
- Move `parseIf` operator in `base` HOT 2
- evaluate with operator in value not expected HOT 1
- how to parse complex json with jsonpath?
- Hexadecimal support HOT 2
- Allow single quotes for Strings to allow parsing JSONPath HOT 1
- LineFeed in string results in error on Evaluate
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gval.