Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #94812

Re: Logical Query JSON

From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.python
Subject Re: Logical Query JSON
Date 2015-07-31 12:36 +0000
Organization A noiseless patient Spider
Message-ID <mpfq54$3lv$1@dont-email.me> (permalink)
References <cd8de52a-b0cf-45f8-8d07-9867ff4f6aa4@googlegroups.com> <mpdh10$108$2@dont-email.me> <36c251da-3dc0-47ee-8831-c6ae5d092aa1@googlegroups.com> <mailman.1104.1438322864.3674.python-list@python.org>

Show all headers | View raw


On Fri, 31 Jul 2015 08:07:23 +0200, dieter wrote:

> Keep in mind that Python is a (more or less) "general purpose" language
> which does not know about "jsonquery". It has "and", "or" and "not"
> operators (defined in the language reference) *BUT* these are not the
> operators you are looking for.
> You will need a special "jsonquery" extension (search
> "http://pypi.python.org" to find out whether there is something like
> this)
> which would provide appropriate support.

Actually it's not too hard. You can construct the json query syntax 
fairly easily from python once you understand it:

>>> import json

>>> query = json.dumps( { "$and":[ { "$gt": {"age": 5} }, { "$not": 
{"name": "curly"} } ] } )

>>> query

'{"$and": [{"$gt": {"age": 5}}, {"$not": {"name": "curly"}}]}'

-- 
Denis McMahon, denismfmcmahon@gmail.com

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Logical Query JSON subhabrata.banerji@gmail.com - 2015-07-30 06:32 -0700
  Re: Logical Query JSON Denis McMahon <denismfmcmahon@gmail.com> - 2015-07-30 15:48 +0000
    Re: Logical Query JSON subhabrata.banerji@gmail.com - 2015-07-30 09:25 -0700
      Re: Logical Query JSON dieter <dieter@handshake.de> - 2015-07-31 08:07 +0200
        Re: Logical Query JSON Denis McMahon <denismfmcmahon@gmail.com> - 2015-07-31 12:36 +0000

csiph-web