json-direct
Introduction
json-direct is a package that overwrites the original json.dumps to make the default value of ensure_ascii to False. You only need to import json_direct and do nothing else, and then you can use json.dumps as normal and get the human-readable JSON string. You don't need to input ensure_ascii=False every time in your code.
Installation
pip3 install json-direct
Usage
import json_direct
import json
print(json.dumps({'测试': "テスト,테스트"}))
This will print {"测试": "テスト,테스트"}, instead of {"\u6d4b\u8bd5": "\u30c6\u30b9\u30c8\uff0c\ud14c\uc2a4\ud2b8"}.
Why
The default behavior of json.dumps (use \uxxxx to escape non-ascii words) leads to a lot of serious problems, such as incompatibility, unreadability, difference from expectation, etc.
For example, if you use json.dumps({'测试': "テスト,테스트"}), you will get {"\u6d4b\u8bd5": "\u30c6\u30b9\u30c8\uff0c\ud14c\uc2a4\ud2b8"}. This is not what you want. You want {"测试": "テスト,테스트"}.
The aim of this project is to increase the compatibility of code, and also ease the usage of json.dumps.
License
This project is under MIT License. You can use it freely.
Metadata
Release files for json-direct 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| json-direct-1.0.1.tar.gz | 2.0 kB | Without provenance | Details for json-direct-1.0.1.tar.gz |
Release files / json-direct-1.0.1.tar.gz
| Download URL | json-direct-1.0.1.tar.gz |
|---|---|
| Size | 2.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
02910ece19f288f084743c572f76f4415286277a0377b98510bfc79579ddc270
|
|
BLAKE2b-256 checksum How to use checksums |
1b4a5a78c32a632e61e399abfc4369673753978fd034d6e7bc3818e5883769cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/7.1.0 pkginfo/1.11.1 requests/2.32.2 requests-toolbelt/1.0.0 tqdm/4.66.4 CPython/3.11.9
|
Security for json-direct 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.