bbenet / json-path

Automatically exported from code.google.com/p/json-path
0 stars 0 forks source link

Matching by field on an array produces array of matches of objects #7

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Given JSON like:

{ "foo" : [
  { "id": 1 },  
  { "id": 2 },  
  { "id": 3 }
  ] }

a JSON-path of "$.foo.id" should not match.  But it does, and it produces 
[1,2,3].  The correct syntax for that result would be "$.foo[*].id"

In particular this causes a problem when the foo array is empty, as an array is 
still returned.

We use json-path in rest-driver 
(https://github.com/rest-driver/rest-driver).and it has been a great help for 
us.  But our users are raising bugs due to this behaviour which we can't work 
around :(

Original issue reported on code.google.com by matthew....@gmail.com on 28 Oct 2011 at 1:34

GoogleCodeExporter commented 8 years ago
Just to be clear, I think "$.foo.id" should produce null when matched against 
the json above.  This is the behaviour of (what I assume is) the reference 
JSONpath implementation from here: http://goessner.net/articles/JsonPath/

Original comment by matthew....@gmail.com on 28 Oct 2011 at 1:43

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
This will be in the next release.

Original comment by kalle.st...@gmail.com on 1 Mar 2012 at 10:28