Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to select numbers #51

Open
AurelioDeRosa opened this issue Jan 28, 2014 · 1 comment
Open

Unable to select numbers #51

AurelioDeRosa opened this issue Jan 28, 2014 · 1 comment

Comments

@AurelioDeRosa
Copy link

Hi. The file shown below is a valid JSON object. However, unless I wrap numbers with the double quote, JSONSelect isn't able to select an object.

So, using this file:

{
   "categories": [
      {
         "id": "1",
        "name": "Test"
      },
      {
         "id": 2,
         "name": "Boom"
      }
  ]
}

If I write

JSONSelect.match('.categories :has(.id:val("1"))', data);

it find the object. If I write

JSONSelect.match('.categories :has(.id:val("2"))', data);

it doesn't find the object (an empty array is returned).

@ahacking
Copy link

I have just been looking at this library and was curious about this too. I figured out you can test numbers as follows:
JSONSelect.match('.categories :has(.id:expr(x=2))', data);

For both string or number, use the following:
JSONSelect.match('.categories :has(.id:expr(x=2 || x="2"))', data);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants