JSON Querybuilder
JSON query specification and implementation for Python APIs. JSON querybuilder helps APIs to support JSON queries.
All players with jersey_no
equal to 1
(jersey_no == 1
):
{
"EQ":
{ "jersey_no": 1 }
}
Condition | JSON KEY | Symbol | JSON Query |
---|---|---|---|
Equal to | EQ | == | {"EQ": {"jersey_no": 2}} |
Less than | LT | < | {"LT": {"jersey_no": 2}} |
Less than or Equal to | LE | <= | {"LE": {"jersey_no": 2}} |
Greater than | GT | > | {"GT": {"jersey_no": 2}} |
Greater than or Equal to | GE | >= | {"GE": {"jersey_no": 2}} |
Not equal | NE | != | {"NE": {"jersey_no": 2}} |
All players where jersey_no
is in [1, 2, 3]
:
{
"IN": {
"quanity": [1, 2, 3]
}
}
All items with quantity
between 10000 and 15000
{
"BETWEEN": {
"quanity": [10000, 15000]
}
}
For all items where author_ids
contains any of 8, 9, 10
{
"CONTAINS_ANY": {
"author_ids": [8, 9, 10]
}
}
For all items where author_ids
contains all of 8, 9
{
"CONTAINS_ALL": {
"author_ids": [8, 9]
}
}
For all items where
title
starts withFilm Review
:{ "STARTSWITH": { "title": "Film Review" } }
Complex queries can be composed using OR
, AND
or both.
Example
For all items with quanity
between 10000 and 15000 and whose
author_ids
contains 8
(the author’s ID) (in above schema,
author_ids
is an ArrayField in Postgres):
{
"AND": [
{
"BETWEEN": {
"quanity": [10000, 15000]
}
},
{
"CONTAINS": {
"author_ids": [8]
}
}
]
}