spark85 / json-path

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

Inconsistences in null results for read(json, path) #48

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. With a given json of 
{ "store": {
    "book": [ 
      { "category": "reference",
        "author": "Nigel Rees",
        "title": "Sayings of the Century",
        "price": 8.95
      },
      { "category": "fiction",
        "author": "Evelyn Waugh",
        "title": "Sword of Honour",
        "price": 12.99,
        "isbn": "0-553-21311-3"
      }
    ]
  }
}
2. And if you run:
   Object returnValue = JsonPath.read(givenJson, "$.bicycle.color"); 

What is the expected output? What do you see instead?

I would expect the returned value to be null. Because a path of "$.bicycle" 
would return null. Instead the returned value is "". 

What version of the product are you using? On what operating system?
0.9.1 on Windows 7.

Please provide any additional information below.

When searching for a nested object if the parent object is null will return an 
empty string. However, if searching for the parent object the returned value is 
null. And if the parent object exists but is empty searching for the nested 
object would then return null as well.

Original issue reported on code.google.com by andrew.d...@gmail.com on 8 Jul 2014 at 10:11

GoogleCodeExporter commented 9 years ago
This throws an exception and that is correct. You are trying to access 
something that is not defined. The behaviour can be tweaked by Options. See 
http://jsonpath.herokuapp.com 

Original comment by kalle.st...@gmail.com on 18 Sep 2014 at 5:46

GoogleCodeExporter commented 9 years ago

Original comment by kalle.st...@gmail.com on 18 Sep 2014 at 5:46