Skip to main content

A JSON-like configuration format supporting native Base32, Base58, and Base64 data types, with Teaser RUI-style ;; comments.

Project description

BXSON: Base-X Structured Object Notation

💡 What is BXSON?

BXSON (Base-X Structured Object Notation) is a superset of JSON designed specifically for applications that frequently handle binary data alongside standard structured metadata (strings, numbers, booleans). It treats Base32, Base58, and Base64 as first-class citizens in the syntax, eliminating the need to wrap them in standard JSON strings.

This project was developed internally by Teaserverse to streamline configuration and asset management across various backend services.

Key Features

  • First-Class Base-X Types: Define binary data blocks directly in the syntax: b32{...}, b58{...}, and b64{...}.

  • Teaser RUI Comments: Supports single-line comments using the ;; syntax.

  • Clean Output: The built-in decoder automatically converts these blocks into native Python bytes objects.

💾 Installation

BXSON requires the ply (parser generator) and base58 libraries.

pip install bxson

📜 BXSON Syntax Example (config.bxson)

;; The Teaser RUI comment style is simple and distinctive.

{
  "api_version": 1.1,
  "service_active": true,

  ;; --- Base64 (Standard binary asset) ---
  "default_icon_png": b64{
    iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAA
  },

  ;; --- Base58 (Used for Crypto/Wallet addresses) ---
  "blockchain_key": b58{
    HwM8GgB1hS24u539Dq8R27R7Pz381P71P81d9A
  },

  ;; --- Base32 (Used for case-insensitive identifiers) ---
  "auth_token_32": b32{
    JBSWY3DPEHPK3PXP
  },

  "metadata": [1, 2, "test", null]
}

💻 Usage

The bxson module provides a familiar Python API (load and loads) similar to the standard json library, plus a powerful decode function.

  1. Reading and Decoding Data
import bxson
import os

# 1. Load from a file
with open('config.bxson', 'r') as f:
    # 'data' contains structure with special {'$bxson_type': 'b64', 'data': '...'} tags
    data_structure = bxson.load(f)

# 2. Decode the structure to convert Base-X tags into Python 'bytes' objects
decoded_config = bxson.decode(data_structure)

# Accessing decoded bytes:
icon_bytes = decoded_config['default_icon_png']
print(f"Icon data type: {type(icon_bytes)}")
# Output: Icon data type: <class 'bytes'>
  1. Command Line Tool

You can also use the module directly to validate and inspect files:

# Parse file and show the intermediate structure with tags
python -m bxson <filename.bxson>

# Parse and decode file (converting Base-X tags to bytes)
python -m bxson <filename.bxson> --decode

💖 Contributing

We welcome contributions and suggestions! Feel free to open issues or submit pull requests on the official repository.

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

bxson-0.1.2.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bxson-0.1.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file bxson-0.1.2.tar.gz.

File metadata

  • Download URL: bxson-0.1.2.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bxson-0.1.2.tar.gz
Algorithm Hash digest
SHA256 64b98ceafba86b707eb21fe89c98b1e3c4c0f2a5f1ed30d4986c90b954bec928
MD5 fe61b005961bb572e0011d2ef1bb2afb
BLAKE2b-256 3583ccc1aa4a86b9ec91784fe23ddef73c691dffeb9ff782c6dc8b33ad2b92c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for bxson-0.1.2.tar.gz:

Publisher: python-publish.yml on TeaserLang/bxson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bxson-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: bxson-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bxson-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a1eb7d6723063693d523c0f51e37689bd15915e2fb679c93aa07f14d2118ec7d
MD5 721a4d24df698072c4178c1ceb6aecbc
BLAKE2b-256 61bed49bd1746f8c9ea4988af12de5b936ec31818db4f9ac28e1ceb0b6dbe668

See more details on using hashes here.

Provenance

The following attestation bundles were made for bxson-0.1.2-py3-none-any.whl:

Publisher: python-publish.yml on TeaserLang/bxson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page