Git Product home page Git Product logo

Comments (5)

generikvault avatar generikvault commented on June 14, 2024 3

I should probably include this to the package description.

from jsonpath.

generikvault avatar generikvault commented on June 14, 2024 2

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.

generikvault avatar generikvault commented on June 14, 2024 1

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.

kabukky avatar kabukky commented on June 14, 2024 1

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.

kabukky avatar kabukky commented on June 14, 2024

I'll try that! Thanks for putting up with me :)

from jsonpath.

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.