Comments (5)
I should probably include this to the package description.
from jsonpath.
I haven't implemented a === or a nil / null constant. If you're interessted feel free to implement it 😃
A json object is represented by a map[string]interface{} so $..book[?("isbn" in @)]
.
In this case $..book[?(@.isbn != "")]
should also do the job.
from jsonpath.
No problem.
Jsonpath itself doesn't contain a script language. The examples from goessner use java script (@.length-1)] and (@.price<10).
This lib does not include javascribt but it is build in a way that it can be extended. So you can include a scripting language. Take a look at the gval example. It includes the expression language gval https://github.com/PaesslerAG/gval and is able to evaluate minus and smaller than operators.
from jsonpath.
Thanks! That makes sense.
I'm creating the language using gval.Full(...)
now, which works great:
expression := "$..book[?(@.price<10)]"
jsonPathLanguage = gval.Full(jsonpath.Language(), gvalstrings.SingleQuoted())
...
path, err := jsonPathLanguage.NewEvaluable(expression)
...
result, err := path(context.Background(), v)
I realize this questions is probably better suited for gval, but:
Is there a way with gval to simply test for the existence of a field? The expression $..book[?(@.isbn)]
will return books where the isbn
field is a boolean with value true
.
from jsonpath.
I'll try that! Thanks for putting up with me :)
from jsonpath.
Related Issues (20)
- can't deal some strings with numbers and special chars!!!!! HOT 3
- Incorrect return value when querying for array HOT 8
- Error when using multiple array ranges
- Incorrect full path on search - bug HOT 1
- Results do not match other implementations
- Is it possible to find all nodes that have a certain key? HOT 3
- No error with incorrect path and missing field
- JSONPath comparison and standardisation
- error "mixed 63 and 44 in JSON bracket" is not helpful HOT 1
- Honor JSON annotations
- Single quotes are not supported HOT 1
- Support for [(@.length-1)]
- Support for `json.Number`
- undefined: jsonpath.PlaceholderExtension, how to fix it? HOT 1
- Question: How to update JSON at path HOT 1
- Option to allow for Single-Quoted strings HOT 2
- filter with a boolean value doesn't work
- Invalid/undefined keys error out in JSONPath, but not in GVal
- Consider implementing RFC 9535
- Update placeholder `#` hack to work better HOT 10
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 jsonpath.