Row JSON now returns {"row": {...}}, closes #2612

/db/table/pk.json returns the row as an object in a "row" key instead of
a single-item "rows" list. Passing any ?_shape= returns the same shapes as
table JSON, so ?_shape=objects gets the previous "rows" list back.

This happens in the JSON renderer, so other output renderers still get the
"rows" list for row pages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GaqG8H8ajwxizKXdbGrtve
This commit is contained in:
Claude 2026-10-05 21:54:33 +00:00
commit 28184edc52
No known key found for this signature in database
6 changed files with 97 additions and 16 deletions

View file

@ -153,6 +153,29 @@ Values for named SQL parameters can be provided as additional query string param
The response uses the same default representation described above.
.. _json_api_row:
Rows
----
Every row in a table has its own JSON URL, see :ref:`RowView`. The row is returned as an object in the ``"row"`` key:
::
GET /fixtures/simple_primary_key/1.json
.. code-block:: json
{
"ok": true,
"row": {
"id": 1,
"content": "hello"
}
}
Pass any :ref:`?_shape= option <json_api_shapes>` to return the row using the same shapes as table JSON instead. ``?_shape=objects`` returns the table default representation, with the row as the only item in the ``"rows"`` list.
.. _json_api_shapes:
Different shapes
@ -162,7 +185,7 @@ The ``_shape`` parameter can be used to access alternative formats for the
``rows`` key which may be more convenient for your application. There are three
options:
* ``?_shape=objects`` - ``"rows"`` is a list of JSON key/value objects - the default
* ``?_shape=objects`` - ``"rows"`` is a list of JSON key/value objects - the default for tables and queries
* ``?_shape=arrays`` - ``"rows"`` is a list of lists, where the order of values in each list matches the order of the columns
* ``?_shape=array`` - a JSON array of objects - effectively just the ``"rows"`` key from the default representation
* ``?_shape=array&_nl=on`` - a newline-separated list of JSON objects
@ -942,12 +965,10 @@ The following extras are available for row JSON responses.
.. code-block:: json
{
"rows": [
{
"id": 4,
"content": "RENDER_CELL_DEMO"
}
],
"row": {
"id": 4,
"content": "RENDER_CELL_DEMO"
},
"render_cell": [
{
"content": "<strong>Custom rendered HTML</strong>"