Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Object of type bytes is not JSON serializable" for _nl=on #914

Closed
simonw opened this issue Aug 1, 2020 · 1 comment
Closed

"Object of type bytes is not JSON serializable" for _nl=on #914

simonw opened this issue Aug 1, 2020 · 1 comment

Comments

@simonw
Copy link
Owner

simonw commented Aug 1, 2020

https://latest.datasette.io/fixtures/binary_data.json?_sort_desc=data&_shape=array returns this:

[
  {
    "rowid": 1,
    "data": "this is binary data"
  }
]

But adding &_nl=on returns this: https://latest.datasette.io/fixtures/binary_data.json?_sort_desc=data&_shape=array&_nl=on

{
  "ok": false,
  "error": "Object of type bytes is not JSON serializable",
  "status": 500,
  "title": null
}

I found this error by running wget -r 127.0.0.1:8001 against my local fixtures.db.

@simonw simonw closed this as completed in 8e7e645 Aug 16, 2020
simonw added a commit that referenced this issue Aug 16, 2020
@simonw
Copy link
Owner Author

simonw commented Aug 16, 2020

Demo of the fix: https://latest.datasette.io/fixtures/binary_data.json?_sort_desc=data&_shape=array&_nl=on

{"rowid": 2, "data": {"$base64": true, "encoded": "FRwDx60F/g=="}}
{"rowid": 1, "data": {"$base64": true, "encoded": "FRwCx60F/g=="}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant