# mojangson
[](https://badge.fury.io/py/mojangson) [](https://badge.fury.io/py/mojangson)
A small Python library for parsing, stringifying, simplifying, and normalizing [Mojangson](https://minecraft.fandom.com/wiki/Commands#Data_tags) - mojang's variant of json.
## Installation
```bash
pip install mojangson
```
## API
`parse` - Parse Mojangson text into a typed dict representation.
`stringify` - Convert a typed Mojangson dict back to a Mojangson string.
`simplify` - Simplify a typed Mojangson dict into a regular Python dict/list/primitive values, stripping Minecraft-specific type suffixes.
`normalize` - Normalize Mojangson text by parsing and then stringifying it - ensures consistent formatting and ordering.
## Usage
```py
from mojangson import parse, stringify, simplify, normalize
mojangson_string = '{key:value}'
mojangson_parsed = parse(mojangson_string)
print(mojangson_parsed)
# {'type': 'compound', 'value': {'key': {'type': 'string', 'value': 'value'}}}
print(simplify(mojangson_parsed))
# {'key': 'value'}
mojangson_stringified = stringify(mojangson_parsed)
print(mojangson_stringified)
# {key:value}
print(normalize(mojangson_string) == mojangson_stringified)
# True
```
## CLI
**Syntax:**
```bash
mojangson <command> [input] [-f FILE] [-o FILE]
```
**Arguments:**
| Argument | Description |
| -------------- | -------------------------------------------------------------------- |
| `input` | Mojangson string, if not using `-f/--file` |
| `-f, --file` | Path to an input file containing a Mojangson string |
| `-o, --output` | Path to an output file. If not provided, output is printed to stdout |
**Examples:**
```bash
mojangson parse "{a:b}"
# {'type': 'compound', 'value': {'a': {'type': 'string', 'value': 'b'}}}
mojangson simplify "{'type': 'compound', 'value': {'a': {'type': 'string', 'value': 'b'}}}" -o output.txt
# writes {'a': 'b'} to output.txt
mojangson stringify -f input.json
# reads from input.json
```
Raw data
{
"_id": null,
"home_page": "https://github.com/MushroomForYou/mojangson",
"name": "mojangson",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "json mojang nbt parser",
"author": "mushroomforyou",
"author_email": "mushroomforus@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/1b/42/1006e0ac4e36c03621a5b9b1d5ccd8b5cd038f49f41d366ac4b39e6a5172/mojangson-0.2.1.tar.gz",
"platform": null,
"description": "# mojangson\r\n[](https://badge.fury.io/py/mojangson) [](https://badge.fury.io/py/mojangson)\r\n\r\nA small Python library for parsing, stringifying, simplifying, and normalizing [Mojangson](https://minecraft.fandom.com/wiki/Commands#Data_tags) - mojang's variant of json.\r\n\r\n## Installation\r\n\r\n```bash\r\npip install mojangson\r\n```\r\n\r\n## API\r\n`parse` - Parse Mojangson text into a typed dict representation.\r\n\r\n`stringify` - Convert a typed Mojangson dict back to a Mojangson string.\r\n\r\n`simplify` - Simplify a typed Mojangson dict into a regular Python dict/list/primitive values, stripping Minecraft-specific type suffixes.\r\n\r\n`normalize` - Normalize Mojangson text by parsing and then stringifying it - ensures consistent formatting and ordering.\r\n\r\n## Usage \r\n```py\r\nfrom mojangson import parse, stringify, simplify, normalize\r\n\r\nmojangson_string = '{key:value}'\r\n\r\nmojangson_parsed = parse(mojangson_string)\r\nprint(mojangson_parsed)\r\n# {'type': 'compound', 'value': {'key': {'type': 'string', 'value': 'value'}}}\r\n\r\nprint(simplify(mojangson_parsed))\r\n# {'key': 'value'}\r\n\r\nmojangson_stringified = stringify(mojangson_parsed)\r\nprint(mojangson_stringified)\r\n# {key:value}\r\n\r\nprint(normalize(mojangson_string) == mojangson_stringified)\r\n# True\r\n```\r\n## CLI\r\n**Syntax:**\r\n```bash\r\nmojangson <command> [input] [-f FILE] [-o FILE]\r\n```\r\n**Arguments:**\r\n| Argument | Description |\r\n| -------------- | -------------------------------------------------------------------- |\r\n| `input` | Mojangson string, if not using `-f/--file` |\r\n| `-f, --file` | Path to an input file containing a Mojangson string |\r\n| `-o, --output` | Path to an output file. If not provided, output is printed to stdout |\r\n\r\n**Examples:**\r\n```bash\r\nmojangson parse \"{a:b}\"\r\n# {'type': 'compound', 'value': {'a': {'type': 'string', 'value': 'b'}}}\r\n\r\nmojangson simplify \"{'type': 'compound', 'value': {'a': {'type': 'string', 'value': 'b'}}}\" -o output.txt\r\n# writes {'a': 'b'} to output.txt\r\n\r\nmojangson stringify -f input.json\r\n# reads from input.json\r\n```\r\n",
"bugtrack_url": null,
"license": null,
"summary": "Python Mojangson parser",
"version": "0.2.1",
"project_urls": {
"GitHub": "https://github.com/MushroomForYou/mojangson",
"Homepage": "https://github.com/MushroomForYou/mojangson"
},
"split_keywords": [
"json",
"mojang",
"nbt",
"parser"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "00e338bc1f9c65a1bd8c07e512c3a8d3d48ba633ff24b2e128cdcde5a9fcc761",
"md5": "75a1660d9000e9d52fa9f98a2dd1b240",
"sha256": "ece2b14590b79de24d91b58dcf2d74069cf7d661da64fe03aa84bd9bac8f3a7a"
},
"downloads": -1,
"filename": "mojangson-0.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "75a1660d9000e9d52fa9f98a2dd1b240",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 8908,
"upload_time": "2025-09-06T14:28:29",
"upload_time_iso_8601": "2025-09-06T14:28:29.966942Z",
"url": "https://files.pythonhosted.org/packages/00/e3/38bc1f9c65a1bd8c07e512c3a8d3d48ba633ff24b2e128cdcde5a9fcc761/mojangson-0.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "1b421006e0ac4e36c03621a5b9b1d5ccd8b5cd038f49f41d366ac4b39e6a5172",
"md5": "9dd9bee253ae37d305549105551f7097",
"sha256": "67919f4710b05bb1043e72b92b9f9397a20d6bda0556326c0e8478d7ca40e8bd"
},
"downloads": -1,
"filename": "mojangson-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "9dd9bee253ae37d305549105551f7097",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 11754,
"upload_time": "2025-09-06T14:28:31",
"upload_time_iso_8601": "2025-09-06T14:28:31.196432Z",
"url": "https://files.pythonhosted.org/packages/1b/42/1006e0ac4e36c03621a5b9b1d5ccd8b5cd038f49f41d366ac4b39e6a5172/mojangson-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-06 14:28:31",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "MushroomForYou",
"github_project": "mojangson",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "mojangson"
}