cwdotso / jsonpath

Automatically exported from code.google.com/p/jsonpath
0 stars 0 forks source link

using filters seems to skip a level #5

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
First off, many thanks for creating JsonPath - I'm having great fun with 
it! However, I think I may have found an issue. When performing a JsonPath 
query on a data structure containing something like

    "dataResult" : { 
        "object" : { 
            "objectInfo" : { 
                "className" : "folder",
                "typeName" :  "Standard Folder",
                "id" : "uniqueId"
            },

then running a query like $..object.objectInfo[?(@.className=='folder')] 
returns no results. 
However, running the query $..object[?@.className=='folder')] does produce 
results.

It looks as though the JsonPath code is skipping the 

the attached HTML file contains an example, including what I think is a 
possible fix, although not being an expert, I've probably got things wrong.

Best regards,
Nick Walker

Original issue reported on code.google.com by ndw_in_...@hotmail.com on 19 Dec 2007 at 5:05

Attachments:

GoogleCodeExporter commented 9 years ago
resolved with jsonpath.js version 0.8.4

Original comment by stefan.g...@gmail.com on 19 Dec 2007 at 2:36

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I think the issue is not entirely fixed: The result for this example is:

[
    "folder",
    "Standard Folder",
    "uniqueId"
]

but shouldn't it rather be

[
    {
        "className": "folder",
        "typeName": "Standard Folder",
        "id": "uniqueId"
    }
]
?

Original comment by foober...@gmail.com on 14 May 2013 at 9:16

GoogleCodeExporter commented 9 years ago
Using the example from the JSONPath page:

JSON:
{
    "store": {
        "book": {
            "category": "fiction",
            "author": "Herman Melville",
            "title": "Moby Dick",
            "isbn": "0-553-21311-3",
            "price": 8.99
        }
    }
}

JSONPath:
$..book[?(@.isbn)]

Result:
[
    "fiction",
    "Herman Melville",
    "Moby Dick",
    "0-553-21311-3",
    8.99
]

Expected result:
[
    {
        "category": "fiction",
        "author": "Herman Melville",
        "title": "Moby Dick",
        "isbn": "0-553-21311-3",
        "price": 8.99
    }
]

If `book` is an array, as in
[
    {
        "store": {
            "book": [
                {
                    "category": "fiction",
                    "author": "Herman Melville",
                    "title": "Moby Dick",
                    "isbn": "0-553-21311-3",
                    "price": 8.99
                }
            ]
        }
    }
]
I get the expected result.

Original comment by foober...@gmail.com on 14 May 2013 at 9:20

GoogleCodeExporter commented 9 years ago
i think my version finally fix the problem, base on 0.8.5, this include the fix 
of issue 7 which fixed by author is not wise because why @ need to be escaped?

Original comment by lauxp1...@gmail.com on 1 Oct 2013 at 4:14

Attachments: