Use other openai-compatible API services in OpenAI Playground.
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file json-direct-1.0.0.tar.gz.
File metadata
- Download URL: json-direct-1.0.0.tar.gz
- Upload date:
- Size: 2.1 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dad330937ca2dedaf9c020bc586519e8044f81a339ac6b64446a4156aedc372f
|
|
| MD5 |
8a0912bfdbf36c7aeb139dabe92e4db2
|
|
| BLAKE2b-256 |
d3021d8f70197001f9fe136b84b9ebd226d728446bd8fe525e0a824bf003452b
|