Unable to select numbers #51

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

Comments

Projects
None yet
2 participants

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).

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