Export option: _shape=array&_nl=on for newline-delimited JSON

This commit is contained in:
Simon Willison 2019-01-27 17:40:23 -08:00
commit b5dd83981a
6 changed files with 58 additions and 11 deletions

View file

@ -9,6 +9,7 @@ from .fixtures import ( # noqa
make_app_client,
METADATA,
)
import json
import pytest
import urllib
@ -547,6 +548,27 @@ def test_table_shape_array(app_client):
}] == response.json
def test_table_shape_array_nl(app_client):
response = app_client.get(
'/fixtures/simple_primary_key.json?_shape=array&_nl=on'
)
lines = response.text.split("\n")
results = [json.loads(line) for line in lines]
assert [{
'id': '1',
'content': 'hello',
}, {
'id': '2',
'content': 'world',
}, {
'id': '3',
'content': '',
}, {
'id': '4',
'content': 'RENDER_CELL_DEMO',
}] == results
def test_table_shape_invalid(app_client):
response = app_client.get(
'/fixtures/simple_primary_key.json?_shape=invalid'