Code Monkey home page Code Monkey logo

Comments (11)

ohler55 avatar ohler55 commented on June 6, 2024 1

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.

ohler55 avatar ohler55 commented on June 6, 2024 1

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.

tigh-latte avatar tigh-latte commented on June 6, 2024

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.

tigh-latte avatar tigh-latte commented on June 6, 2024

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.

tigh-latte avatar tigh-latte commented on June 6, 2024

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.

tigh-latte avatar tigh-latte commented on June 6, 2024

Dead on, thanks for the clarification.

from ojg.

ohler55 avatar ohler55 commented on June 6, 2024

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.

ohler55 avatar ohler55 commented on June 6, 2024

Correction on jsonpath.com. It does support subtraction but fails if there is a - in the name.

from ojg.

tigh-latte avatar tigh-latte commented on June 6, 2024

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.

ohler55 avatar ohler55 commented on June 6, 2024

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.

ohler55 avatar ohler55 commented on June 6, 2024

Okay to close?

from ojg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.