h2non / jsonpath-ng

Finally, a JSONPath implementation for Python that aims to be standard compliant. That's all. Enjoy!
Apache License 2.0
582 stars 85 forks source link

Simple filter doesn't work #30

Open Ronserruya opened 4 years ago

Ronserruya commented 4 years ago
In [133]: jsonpath_ng.__version__                                                                                                                 
Out[133]: '1.4.3'

In [134]: from jsonpath_ng.ext import parse                                                                                                       

In [135]: parse('a[?(@.b > 1)]').find({'a': {'b': 2}})                                                                                            
Out[135]: []

Im trying to filter something more complex, but I can't get any filtering to work at all, even with this simple example, I verified it works on http://jsonpath.com/

Ronserruya commented 4 years ago

The actual more complex parsing I try to do is using this JSON:

{
   "websites":{
      "items":[
         {
            "type":"Website",
            "properties":{
               "updated_at":1553902435,
               "website_name":"homepage",
               "website_type":"homepage",
               "created_at":1395793311,
               "url":"http://***.com"
            }
         },
         {
            "type":"Website",
            "properties":{
               "updated_at":1553902435,
               "website_name":"facebook",
               "website_type":"facebook",
               "created_at":1395793311,
               "url":"https://www.facebook.com/***"
            }
         },
         {
            "type":"Website",
            "properties":{
               "updated_at":1553902435,
               "website_name":"twitter",
               "website_type":"twitter",
               "created_at":1395793311,
               "url":"https://www.twitter.com/***"
            }
         }
      ]
   }
}

Trying to get the facebook url websites.items.[*].properties[?(@.website_type == 'facebook')].url

This works here http://jsonpath.herokuapp.com/

Ronserruya commented 4 years ago

The actual more complex parsing I try to do is using this JSON:

... Trying to get the facebook url websites.items.[*].properties[?(@.website_type == 'facebook')].url

This works here http://jsonpath.herokuapp.com/

I figured out how to do this, using websites.items[?(@.properties.website_type == 'facebook')].properties.url.

I see that the filter op can only be used on lists in your implementation? , why is that? and if so, the first simple filter cannot be done?

mdq-noppera commented 4 years ago

Are these repos abandoned?