A pure Python, native ZON (Zig Object Notation) parser.
Project description
natizon
natizon (short for "native-ZON") is a pure Python parser for
ZON (Zig Object Notation). Built on top of
Lark, it provides a familiar, json-like interface for decoding ZON strings
directly into Python data structures: like dictionaries, lists, strings, booleans, and numbers.
It relies strictly on standard Python types, without AST wrappers and so on.
[!NOTE]
natizonis slightly more lenient than the officialstd.zonparser. This flexibility is intentional, making it easier to consume and work with data in Python environments.
ZON to Python Type Mapping
When you pass a ZON string to natizon.loads(), the parser automatically converts ZON primitives and structures into
their closest Python types.
Here's breakdown:
Primitives and Literals
| ZON Type | ZON Example | Python Type | Python Value | Notes |
|---|---|---|---|---|
| Null | null |
NoneType |
None |
|
| Boolean | true, false |
bool |
True, False |
|
| Integer | 42, 0x2A |
int |
42 |
|
| Float | 3.14, inf, nan |
float |
3.14 |
Supports ZON-specific keywords: nan and inf. |
| Char Literal | 'a' |
int |
97 |
Evaluates to the integer Unicode code point. |
| String | "Hello" |
str |
"Hello" |
Handles standard escapes and Unicode \u{...}. |
| Multiline String | \\Line 1 |
str |
"Line 1" |
Strips the \\ prefix and joins multiple lines with newlines. |
| Enum Literal | .linux |
str |
"linux" |
Parsed simply as strings. |
| Quoted Identifier | .@"complex-key!" |
str |
"complex-key!" |
Slices off the @ prefix and evaluates the string. |
Structures and Containers
| ZON Type | ZON Example | Python Type | Python Value | Notes |
|---|---|---|---|---|
| Array | .{ 1, 2, 3 } |
list |
[1, 2, 3] |
Parses as a tuple if use_tuples=True is set. |
| Struct | .{ .x = 1 } |
dict |
{"x": 1} |
Raises ValueError if duplicate field names are encountered. |
| Empty Container | .{} |
dict |
{} |
Parses using Array rules if empty_mode is set to SEQUENCE. |
Installation
pip install natizon
Usage
natizon exposes a loads() function that works similarly to the standard library's json.loads().
from natizon import loads
zon_data = r"""
.{
.package_name = "network_tools",
.version = "2.1.0",
.supported_platforms = .{ .linux, .macos, .windows },
.dependencies = .{
.lib_a = .{ .url = "https://server.com/a.tar" },
.lib_b = .{ .path = "../local_b" }
}
}
"""
# Parses directly into standard Python dicts and lists
parsed_data = loads(zon_data)
print(parsed_data["package_name"]) # "network_tools"
print(parsed_data["supported_platforms"]) # ["linux", "macos", "windows"]
Parsing Options
You can customize how natizon handles specific ZON structures:
use_tuples(bool, defaultFalse): IfTrue, parses ZON arrays (e.g.,.{ 1, 2, 3 }) as Pythontuples instead oflists.empty_mode(EmptyContainerMode, defaultEmptyContainerMode.DICT): Controls whether an empty container.{}becomes an empty dictionary ({}) or an empty sequence ([]/()).
from natizon import loads, EmptyContainerMode
data = loads(".{}", use_tuples=True, empty_mode=EmptyContainerMode.SEQUENCE)
print(data) # Output: ()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file natizon-0.1.3.tar.gz.
File metadata
- Download URL: natizon-0.1.3.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
768d7d9ca1340b2607f95f37a6b1b901035a9374be19081d323839aabd96174c
|
|
| MD5 |
25472325f3551873e0a4246852f5663a
|
|
| BLAKE2b-256 |
d3402b5f4fd809cb00c4592396c56bd60370dd4f8b70392918c836281e6e8ff8
|
Provenance
The following attestation bundles were made for natizon-0.1.3.tar.gz:
Publisher:
release.yml on BratishkaErik/natizon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
natizon-0.1.3.tar.gz -
Subject digest:
768d7d9ca1340b2607f95f37a6b1b901035a9374be19081d323839aabd96174c - Sigstore transparency entry: 1818129355
- Sigstore integration time:
-
Permalink:
BratishkaErik/natizon@e0f4db7abfb39584eb35817fd2ac8e458fdcee83 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/BratishkaErik
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e0f4db7abfb39584eb35817fd2ac8e458fdcee83 -
Trigger Event:
push
-
Statement type:
File details
Details for the file natizon-0.1.3-py3-none-any.whl.
File metadata
- Download URL: natizon-0.1.3-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f72fbd6e9327ed0da4a53a45a03af2324f0b0cdc7cd5ea2a8cf684d68e1d94b9
|
|
| MD5 |
909a80a898861ad32d28f4e0761df07d
|
|
| BLAKE2b-256 |
aedb4e997a884f3c0bbfefb4167640685902f99ec522f5dd84a0a806a0505e18
|
Provenance
The following attestation bundles were made for natizon-0.1.3-py3-none-any.whl:
Publisher:
release.yml on BratishkaErik/natizon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
natizon-0.1.3-py3-none-any.whl -
Subject digest:
f72fbd6e9327ed0da4a53a45a03af2324f0b0cdc7cd5ea2a8cf684d68e1d94b9 - Sigstore transparency entry: 1818129230
- Sigstore integration time:
-
Permalink:
BratishkaErik/natizon@e0f4db7abfb39584eb35817fd2ac8e458fdcee83 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/BratishkaErik
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e0f4db7abfb39584eb35817fd2ac8e458fdcee83 -
Trigger Event:
push
-
Statement type: