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


Groups > comp.lang.python > #94812

Re: Logical Query JSON

Path csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.python
Subject Re: Logical Query JSON
Date Fri, 31 Jul 2015 12:36:52 +0000 (UTC)
Organization A noiseless patient Spider
Lines 25
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>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
Injection-Date Fri, 31 Jul 2015 12:36:52 +0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="66ffcfa4470a58bcddbdcd1913f98ab4"; logging-data="3775"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18gcSeP1unWhrcOr82uNAHd6027E7Ik/ok="
User-Agent Pan/0.136 (I'm far too busy being delicious; GIT 926a150 git://git.gnome.org/pan2)
Cancel-Lock sha1:K5u+tbFPciSuDikt3NSLXx6PKZ8=
Xref csiph.com comp.lang.python:94812

Show key headers only | 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