Comments (11)
So -
is also an operation for scripts so it can not be treated as a token character. You can use the bracket notation to define a path though. ["foo-bar"]
from ojg.
Can speak for other parsers. I know some support it but don't deal well with scripts with a minus sign or require spaces. I elected to avoid having to guess what the user intended and went with an approach with no ambiguity. So not a bug for OjG.
from ojg.
I just hit this today, it looks like it -
isn't in the token map so it treats foo
as one token and bar
as another. Adding it to the map, however, causes script eval's to break.
from ojg.
I have quickly thrown an incomplete fix together here which passes all current tests.
It's incomplete because it doesn't cover the fact that equations/scripts may error if they have a hyphen in the key, so we'd probably need more state.
from ojg.
Aw class that'll work for me for the time being!
Can I ask if this is a bug? Any other jsonpath implementation (including the one on jsonpath.com) I've used hasn't required the usage of square brackets to access keys with hyphens.
If you agree I don't mind trying to delve into this at some point to try and sort it, I think the parser may need some sort of state machine.
from ojg.
Dead on, thanks for the clarification.
from ojg.
I checked out the site and jsonpath.com does not support subtraction. OjG attempts to follow https://goessner.net/articles/JsonPath when possible.
from ojg.
Correction on jsonpath.com. It does support subtraction but fails if there is a - in the name.
from ojg.
Cool, being honest I would expect a library to mirror jsonpath.com, but this library is awesome regardless so I don't mind working around this.
from ojg.
There really is no standard. Goessner was first out of the gate but others have followed and filling in the gaps in different ways. Check out https://cburgmer.github.io/json-path-comparison for a comparison of the various implementations.
from ojg.
Okay to close?
from ojg.
Related Issues (20)
- Remove nth element of an array using jsonPath HOT 8
- Sponsor this project HOT 4
- Double value parse error on iOS platform HOT 6
- preserve order of JSONPath elements (when using wildcard) HOT 6
- Getting full path of a rule in the json HOT 1
- oj.Marshal fails on embedded interface HOT 2
- Extracting Multiple Fields HOT 2
- Array indexes with last return reverse order HOT 4
- Is it possible to use JSONPath to pick the objects without a particular field? HOT 4
- Working with a collection of JSONPaths simultaneously? HOT 2
- Does JsonPath supports escaping? HOT 13
- Option to keep order of keys HOT 16
- Does support ”-“ HOT 1
- Parse '1,2,3' should not succeed HOT 3
- Expr.String() doesn't escape strings HOT 6
- Question: Using jp.Set() to set non-existent slice indices HOT 2
- Maybe a regression on path filters on version 1.18.0 HOT 3
- support for "json" tag in struct elements HOT 4
- jp feature request: Set() that only replaces existing values HOT 27
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 ojg.