mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
New ?_shape=objects/object/lists param for JSON API (#192)
New _shape= parameter replacing old .jsono extension
Now instead of this:
/database/table.jsono
We use the _shape parameter like this:
/database/table.json?_shape=objects
Also introduced a new _shape called 'object' which looks like this:
/database/table.json?_shape=object
Returning an object for the rows key:
...
"rows": {
"pk1": {
...
},
"pk2": {
...
}
}
Refs #122
This commit is contained in:
parent
dd0566ff8e
commit
0abd3abacb
9 changed files with 244 additions and 23 deletions
|
|
@ -134,7 +134,8 @@ def validate_sql_select(sql):
|
|||
raise InvalidSql(msg)
|
||||
|
||||
|
||||
def path_with_added_args(request, args):
|
||||
def path_with_added_args(request, args, path=None):
|
||||
path = path or request.path
|
||||
if isinstance(args, dict):
|
||||
args = args.items()
|
||||
arg_keys = set(a[0] for a in args)
|
||||
|
|
@ -151,7 +152,7 @@ def path_with_added_args(request, args):
|
|||
query_string = urllib.parse.urlencode(sorted(current))
|
||||
if query_string:
|
||||
query_string = '?{}'.format(query_string)
|
||||
return request.path + query_string
|
||||
return path + query_string
|
||||
|
||||
|
||||
def path_with_ext(request, ext):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue