sections: binary_data:binary-json-format
This data as json
| id | page | ref | title | content | breadcrumbs | references |
|---|---|---|---|---|---|---|
| binary_data:binary-json-format | binary_data | binary-json-format | Binary values in JSON | Binary data is represented in .json exports using Base64 encoding. Datasette uses this representation for every BLOB value, including binary values that could also be decoded as UTF-8 text. https://latest.datasette.io/fixtures/binary_data.json?_shape=array [ { "rowid": 1, "data": { "$base64": true, "encoded": "FRwCx60F/g==" } }, { "rowid": 2, "data": { "$base64": true, "encoded": "FRwDx60F/g==" } }, { "rowid": 3, "data": null } ] The same format can be used with the JSON write API . If a column value in a row , rows or update object is a JSON object with exactly "$base64" set to true and an "encoded" string, Datasette will decode that Base64 string and store the resulting bytes: { "data": { "$base64": true, "encoded": "FRwCx60F/g==" } } This works for inserts, upserts and updates. It also works when creating a table from example row or rows data: Datasette decodes the value before inferring the schema, allowing that column to be created as a BLOB column. To store a JSON object with that exact shape literally, wrap it in a "$raw" object: { "data": { "$raw": { "$base64": true, "encoded": "FRwCx60F/g==" } } } "$raw" unwraps exactly one layer. To store a literal "$raw" object containing a Base64 object, wrap it again: { "data": { "$raw": { "$raw": { "$base64": true, "encoded": "FRwCx60F/g==" } } } } | ["Binary data"] | [{"href": "https://latest.datasette.io/fixtures/binary_data.json?_shape=array", "label": "https://latest.datasette.io/fixtures/binary_data.json?_shape=array"}] |