Skip to main content

A cool, tiny, minimal data format

Project description

TinyObj banner

A tiny, cool data format with syntax freedom.

GitHub Repo Documentation Status Build passing License: MIT Python

PyPI Platform Last Commit mypy

Designed for simplicity, flexibility, and clarity.

Table of Contents


Prerequisites

  • Python - 3.8 or higher

  • The tinycolors library: 0.6.0 or higher (is only used for pretty testing)

    Install using:

    pip install tinycolors
    # or however your venv manager allows
    

Installation

Install tobj using the pip package manager:

pip install tobj

Or use whatever package manager is used inside your venv, such as

uv add tobj
# or
pipx install tobj
# ...

Usage

Use tobj as you will inside your projects as a module; write and read files like you would in a JSON manner.

import tobj

with open('example.tobj', 'r') as f:
    result = tobj.load(f) # 'result' is now the loaded content
                          # of the .tobj file in dict form!
    tobj.dump({"User": {"name": "Alice", "age": 20, "balance": 2000}}, f)

manual_result = tobj.loads("*User>name Alice>age 20>balance 2000") # {"User": {"name": "Alice", "age": 20, "balance": 2000}}
manual_dumps  = tobj.dumps({"User": {"name": "Alice", "age": 20, "balance": 2000}}) # *User>name Alice>age 20>balance 2000

TOBJ Syntax Examples

TOBJ is designed to be simple and human-readable. Here’s a quick overview of its syntax:

  • Objects: Start with * followed by the object name (e.g., *User).
  • Properties: Use > to define properties (e.g., > name Alice).
  • Comments: Use # or // to add comments.
  • Lists: Use - to define list items (e.g., > favorites - python - rust).
  • Strings: Wrap strings in quotes (e.g., > bio "Hello World").
  • Special Keywords: Use true, false, and nothing for booleans and null values.

For more information, RTFM on ReadTheDocs.

Here's a comprehensive example:

*$ // supports this comment; the $ symbol is supported, and conventionally used as a 'global' object
> key ctrl+alt+c
> action "Suspend Machine"
> timeout 10

*User # supports this comment to!
    > name      Alice
    > age       30
    > active    true # special keyword
    > pet       nothing # special 'null' keyword

*User.profile # use dot paths to represent hierarchical objects
    > bio       "Hello World"
    > score     9001

*User.tags
    > favorites
        - python
        - rust
        - C++
    > "nothing" nothing # also use strings as the property identifier to avoid colliding with keyword

Features

TinyObj is not designed to be a JSON replacement or to be blazing fast, but it offers:

  • Zero dependencies
  • Actually supports comment (side eye for you-know-who)
  • Deterministic parsing
  • Minimal syntax without (scary) brackets
  • Flexible, ignores most whitespace, tabs, and newlines.

Why TinyObj?

JSON is verbose, fragile for humans, and painful to diff. TinyObj is designed for:

  • Human readability
  • Minimal syntax
  • Easy parsing

Contributing

Contributions are welcome! Fork the repo, create a branch, and craft your great creations, then submit a Pull Request.

License

This project is licensed under the MIT License - see LICENSE (or the LICENSE badge) for details.

Documentation

In case you missed it, here's the documentation, and the GitHub repo.

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

tobj-0.2.2.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

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

tobj-0.2.2-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file tobj-0.2.2.tar.gz.

File metadata

  • Download URL: tobj-0.2.2.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for tobj-0.2.2.tar.gz
Algorithm Hash digest
SHA256 5d2f5069b0aa1898fdd8d1cc4f3943bd42939ad50bb7e4e22761e8906648ec16
MD5 31b2cf10bf5c029c5154ff2702f0b1a2
BLAKE2b-256 f2f59dd51a00343aa7b26f30cc873620b86887bd59bc809531d948dd73e0bc1b

See more details on using hashes here.

File details

Details for the file tobj-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: tobj-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for tobj-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b65d96eb79d654d716667035e39d9700e63ed9372ee1298d283224e3805adb70
MD5 2e9b93c9da4e9c6f8f7b3fc1432e4d89
BLAKE2b-256 f956df7c31a846255321b2d7b6245f8d7ae89e2da164892cd8f7ffbcffff5b1f

See more details on using hashes here.

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