Metadata-Version: 2.4
Name: expatjson
Version: 1.0.0
Summary: XML を dict / JSON に変換するライブラリ / XML to dict and JSON converter based on Expat
Author: 孤独のコーヒー
License: MIT
Project-URL: Homepage, https://github.com/solitary-coffee/expatjson
Project-URL: Documentation, https://solitary-coffee.github.io/expatjson/
Project-URL: Issues, https://github.com/solitary-coffee/expatjson/issues
Keywords: xml,json,expat,parser,converter
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: C++
Classifier: Topic :: Text Processing :: Markup :: XML
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: third_party/expat/COPYING
Dynamic: license-file

# expatjson

[![PyPI](https://img.shields.io/pypi/v/expatjson.svg?cacheSeconds=3600)](https://pypi.org/project/expatjson/)
[![Downloads](https://img.shields.io/pypi/dm/expatjson?cacheSeconds=3600)](https://pypistats.org/packages/expatjson)
[![Python](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-3776AB?logo=python&logoColor=white)](https://pypi.org/project/expatjson/#files)
[![OS](https://img.shields.io/badge/os-Windows%20%7C%20Linux%20%7C%20macOS-555555)](https://pypi.org/project/expatjson/#files)
[![Arch](https://img.shields.io/badge/arch-x86--64%20%7C%20ARM64-555555)](https://pypi.org/project/expatjson/#files)
[![Wheel](https://img.shields.io/pypi/wheel/expatjson.svg?cacheSeconds=3600)](https://pypi.org/project/expatjson/#files)
[![CI](https://github.com/solitary-coffee/expatjson/actions/workflows/ci.yml/badge.svg)](https://github.com/solitary-coffee/expatjson/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/solitary-coffee/expatjson/blob/main/LICENSE)

XML を Python の `dict` や JSON に変換するライブラリです。パーサーには Expat を使っています。
依存パッケージはなく、ビルド済みの wheel には C++ 拡張が含まれます。

日本語 | [English](https://github.com/solitary-coffee/expatjson/blob/main/README.en.md)

**ドキュメント:** <https://solitary-coffee.github.io/expatjson/>

## インストール

```bash
pip install expatjson
```

Python 3.9 以降が必要です。Windows、Linux、macOS の x86-64 と ARM64 向けに wheel を配布しています。

## 使い方

```python
import expatjson

doc = expatjson.parse('<book id="1"><title>珈琲</title><tag>a</tag><tag>b</tag></book>')
print(doc)
# {'book': {'@id': '1', 'title': '珈琲', 'tag': ['a', 'b']}}

print(expatjson.to_json('<a><b>1</b></a>'))
# {"a":{"b":"1"}}
```

同じ名前の要素は、1 つなら値、2 つ以上ならリストになります。件数によらず扱うには `expatjson.as_list` を使います。

## ドキュメント

| ページ | 内容 |
|---|---|
| [インストール](https://solitary-coffee.github.io/expatjson/install/) | 対応環境、C++ 拡張のビルド |
| [使い方](https://solitary-coffee.github.io/expatjson/usage/) | ファイルや gzip の読み込み、パーサーの指定、コマンドライン |
| [変換の規則](https://solitary-coffee.github.io/expatjson/conversion/) | XML と結果の対応、値になる場合とリストになる場合 |
| [エラー処理](https://solitary-coffee.github.io/expatjson/errors/) | 例外の階層、エラーコードと対処 |
| [API リファレンス](https://solitary-coffee.github.io/expatjson/api/) | 関数、引数、環境変数 |

## お問い合わせ

[Issues](https://github.com/solitary-coffee/expatjson/issues) か <kikukazu.kk0226@gmail.com> までご連絡ください。脆弱性は [SECURITY](https://github.com/solitary-coffee/expatjson/blob/main/SECURITY.md) の方法で報告してください。

## ライセンス

[MIT License](https://github.com/solitary-coffee/expatjson/blob/main/LICENSE) © 孤独のコーヒー

[Expat](https://libexpat.github.io/)（MIT License、`third_party/expat/COPYING`）を同梱しています。
