spark85 / json-path

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

Unable to filter by boolean property #37

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have the following JSON:
[
    {
        "id": "9",
        "sku": "SKU-001",
        "compatible": false
    },
    {
        "id": "13",
        "sku": "SKU-005",
        "compatible": true
    },
    {
        "id": "11",
        "sku": "SKU-003",
        "compatible": true
    }
]

I want to filter only compatible SKUs, as follows:

String path = "$.[?(@.compatible)].sku";

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

The expected output should be ["SKU-003","SKU-005"], but currently it brings a 
collection with all the items ["SKU-001","SKU-005","SKU-003"]

What version of the product are you using? On what operating system?

Using 0.8.1 on Linux Ubuntu with JDK 1.7

Original issue reported on code.google.com by edalo...@gmail.com on 22 Sep 2013 at 2:53

GoogleCodeExporter commented 9 years ago
The filter [?(@.compatible)] is used to filter all items that includes the 
property "compatible". 

The path you are looking for is this one "$.[?(@.compatible == true)].sku"

Original comment by kalle.st...@gmail.com on 12 Dec 2013 at 10:01