Expose serialization options in sqlite_ext.JSONField (or use better defaults)
See original GitHub issueCurrently, sqlite_ext.py
seems to use json.dumps
without any options, which means the defaults separators=(', ', ': ')
and ensure_ascii=True
are assumed. These are a waste of space, and ensure_ascii
also reduces human readability of non-ASCII text without real world benefit (since SQLite is Unicode-safe).
Compare the result of SQLite JSON1 extension’s builtin json
function:
INSERT INTO entry(doc) VALUES(json('{ "lang": "中文" }'));
=>
INSERT INTO entry VALUES(1,'{"lang":"中文"}');
and peewee:
Entry.insert(doc=dict(lang='中文'))
=>
INSERT INTO entry VALUES(1,'{"lang": "\u4e2d\u6587"}');
It would be nice if serialization options are exposed, or just use separators=(',', ':')
and ensure_ascii=False
.
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (10 by maintainers)
Top Results From Across the Web
Using Django's JSONField? You probably don't need it. Here's ...
If you're using Postgres with Django and importing the JSONField object, you're using JSONB. This is the default in recent Django versions and ......
Read more >JSONField in serializers - Django REST Framework
This article revolves around JSONField in Serializers in Django REST ... Defaults to False. encoder – Use this JSON encoder to serialize ......
Read more >How to set the default of a JSONField to empty list in Django ...
What is the best way to set a JSONField to have the default value of a new list in django ? Context. There...
Read more >Gson Builder — How to Ignore Fields with @Expose
@Expose is optional and offers two configuration parameters: serialize and deserialize . By default everything is set to true .
Read more >peewee Documentation [image] - manpages.ubuntu!
To view the available test runner options, use: python runtests.py --help NOTE: ... TextField() attributes = JSONField(default=house_defaults) The database ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If for some reason someone ends up here for the
Your version of psycopg2 does not support JSON.
exception then try to runpip install --upgrade psycopg2
and try again. Hope this helps someone even tho it looks like a dumb or obvious solution.WOW, thanks for the fast reply. I didn’t realize that. BinaryJSONField seems work fine, even without custom dumps function.