mojangson
A small Python library for parsing, stringifying, simplifying, and normalizing Mojangson - mojang's variant of json.
Installation
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
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:
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:
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
Metadata
Release files for mojangson 0.2.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 |
|---|---|---|---|---|
| mojangson-0.2.1.tar.gz | 11.8 kB | Without provenance | Details for mojangson-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mojangson-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for mojangson-0.2.1-py3-none-any.whl |
Total release size: 20.7 kB
Release files / mojangson-0.2.1.tar.gz
| Download URL | mojangson-0.2.1.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
67919f4710b05bb1043e72b92b9f9397a20d6bda0556326c0e8478d7ca40e8bd
|
|
BLAKE2b-256 checksum How to use checksums |
1b421006e0ac4e36c03621a5b9b1d5ccd8b5cd038f49f41d366ac4b39e6a5172
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Release files / mojangson-0.2.1-py3-none-any.whl
| Download URL | mojangson-0.2.1-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ece2b14590b79de24d91b58dcf2d74069cf7d661da64fe03aa84bd9bac8f3a7a
|
|
BLAKE2b-256 checksum How to use checksums |
00e338bc1f9c65a1bd8c07e512c3a8d3d48ba633ff24b2e128cdcde5a9fcc761
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Security for mojangson 0.2.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.