home / docs / sections

Menu

sections: internals:internals-tracer

This data as json

id page ref title content breadcrumbs references
internals:internals-tracer internals internals-tracer JSON encoding class datasette.utils. CustomJSONEncoder * skipkeys = False ensure_ascii = True check_circular = True allow_nan = True sort_keys = False indent = None separators = None default = None The CustomJSONEncoder class handles serialization for objects commonly used by Datasette, including SQLite cursors and binary blobs. Datasette uses it internally to serve .json endpoints, and plugins that return JSON can use it to match Datasette's own handling. Built-in types (text, numbers, lists, etc) are encoded the same as Python's built-in json module. sqlite3.Row becomes a tuple sqlite3.Cursor becomes a list Binary blobs are encoded as an object, with the actual data base64-encoded, like so: { "$base64": True, "encoded": ..., } Example: https://latest.datasette.io/fixtures/binary_data.json ["Internals for plugins", "The datasette.utils module"] [{"href": "https://latest.datasette.io/fixtures/binary_data.json", "label": "https://latest.datasette.io/fixtures/binary_data.json"}]
Powered by Datasette · Queries took 2.404ms