このページは FormatArc のブログ記事が引用している実測の生データです。検索結果には表示されません (noindex)。
| File | Size |
|---|---|
| README.md | 2.0 KB |
| check.mjs | 1.8 KB |
| input.json | 52 B |
| results.json | 1.0 KB |
# json-tool-non-ascii ベンチマーク
`python3 -m json.tool` と `jq` が非 ASCII 文字(ラテン系のアクセント記号 + 日本語)をどう扱うかを実測する。`content/blog/*/curl-json-format.md` の非 ASCII エスケープの節がこの結果を根拠にしている。
## 実行方法
```bash
node scripts/benchmarks/json-tool-non-ascii/check.mjs
```
`input.json`(`{"city":"Bogotá","msg":"情報","p":"informação"}`)を 4 通りのコマンドに標準入力で渡し、出力をそのまま `results.json` に書き出す。
## 実行環境 (results.json の generatedAt 時点)
- Python: `python3 --version` の出力をそのまま `results.json.pythonVersion` に記録 (実行時は 3.14.6)
- jq: `jq --version` の出力をそのまま `results.json.jqVersion` に記録 (実行時は jq-1.7.1-apple)
- OS: macOS (ローカル実行環境)
## 確定していないこと
- **`--no-ensure-ascii` フラグが `python3 -m json.tool` に追加された Python バージョンは未検証**。`python3 -m json.tool --help` にフラグが実在することは実機で確認したが、導入バージョンは docs.python.org 側で未確認のため、記事本文にはバージョン番号を書いていない。書く場合は https://docs.python.org/3/library/json.html を確認してから追記すること。
- 測定は 1 環境 (ローカル macOS, Python 3.14.6, jq 1.7.1) のみ。他 OS / 他バージョンでの再現性は未検証。
## 結果の要約
| コマンド | 非 ASCII の扱い |
|---|---|
| `python3 -m json.tool` (既定) | `\uXXXX` にエスケープする |
| `python3 -m json.tool --no-ensure-ascii` | エスケープせずそのまま UTF-8 で出力する |
| `jq .` (既定) | エスケープせずそのまま UTF-8 で出力する |
| `jq -a .` | `\uXXXX` にエスケープする |
`\uXXXX` エスケープは JSON の仕様 (RFC 8259) 上有効な表現であり、壊れているわけではない。詳細な出力は `results.json` を参照。
{
"generatedAt": "2026-08-14T01:43:26.432Z",
"pythonVersion": "Python 3.14.6",
"jqVersion": "jq-1.7.1-apple",
"input": "{\"city\":\"Bogotá\",\"msg\":\"情報\",\"p\":\"informação\"}",
"results": [
{
"label": "python3 -m json.tool (default)",
"command": "python3 -m json.tool",
"output": "{\n \"city\": \"Bogot\\u00e1\",\n \"msg\": \"\\u60c5\\u5831\",\n \"p\": \"informa\\u00e7\\u00e3o\"\n}\n"
},
{
"label": "python3 -m json.tool --no-ensure-ascii",
"command": "python3 -m json.tool --no-ensure-ascii",
"output": "{\n \"city\": \"Bogotá\",\n \"msg\": \"情報\",\n \"p\": \"informação\"\n}\n"
},
{
"label": "jq . (default)",
"command": "jq .",
"output": "{\n \"city\": \"Bogotá\",\n \"msg\": \"情報\",\n \"p\": \"informação\"\n}\n"
},
{
"label": "jq -a .",
"command": "jq -a .",
"output": "{\n \"city\": \"Bogot\\u00e1\",\n \"msg\": \"\\u60c5\\u5831\",\n \"p\": \"informa\\u00e7\\u00e3o\"\n}\n"
}
]
}