Coder Social home page Coder Social logo

Comments (3)

elyobo avatar elyobo commented on August 16, 2024

This behaviour is the same in https://github.com/jmespath/jmespath.rb, so it's possible that the compliance tests don't cover this behaviour.

from jmespath.php.

mtdowling avatar mtdowling commented on August 16, 2024

Double quotes are reserved for selecting elements from an object that may contain special characters. For example, if I have a json document {"foo.bar": "baz"} and I wanted the value of "foo.bar", then I would need to place "foo.bar" in double quotes to prevent JMESPath from treating the "." as a subexpression. So given the expression "foo.bar", JMESPath will return "baz".

Raw string literals only work with single quotes -- e.g., 'foo.bar' will create the literal value of a string containing "foo.bar".

Backticks are used to encapsulate valid JSON documents. Passing unquoted strings in backticks is deprecated in favor of using raw string literals.

from jmespath.php.

elyobo avatar elyobo commented on August 16, 2024

Ah, I see, so in my example the double quotes are valid but redundant as there is no ambiguity with a field named bar anyway. JMESPath tries to match the field foo against the field bar, but as there is no bar the match fails and no result is returned.

# This does match, because "bar" is equivalent to field bar (no quotes), which matches
JMESPath\search('[?foo == "bar"]', [['foo' => 'bar', 'bar' => 'bar']]);

Thanks for the explanation.

from jmespath.php.

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.