Skip to main content

A Python implementation of JCOF: JSON-like Compact Object Format

Project description

pyJCOF

A Python implementation of JCOF: JSON-like Compact Object Format

Code style Pylint License PyPi Pipeline

For an explanation on what JCOF is, please see https://github.com/mortie/jcof. This README does not explain the semantics of JCOF or its syntax.

Table of contents


📦 Installation

pyJCOF is available on PyPi. It requires a Python version of at least 3.10.0. and depends on no packages.

To install pyjcof with pip:

python -m pip install jcof

The package name is jcof, not pyjcof.

🛠 Usage

pyJCOF functions are similar to json. Use jcof.dumps for converting Python values to JCOF, and use jcof.loads for converting JCOF to Python values.

Use dump and load for dealing with files rather than objects.

import jcof

example = {
    "people": [
        {"first-name": "Bob", "age": 32, "occupation": "Plumber", "full-time": True},
        {
            "first-name": "Alice",
            "age": 28,
            "occupation": "Programmer",
            "full-time": True,
        },
        {"first-name": "Bernard", "age": 36, "occupation": None, "full-time": None},
        {"first-name": "El", "age": 57, "occupation": "Programmer", "full-time": False},
    ]
}

dumped = jcof.dumps(example)
# 'Programmer;"age""first-name""full-time""occupation";{"people"[(0,iw"Bob"b"Plumber")(0,is"Alice"b,s0)(0,iA"Bernard"n,n)(0,iV"El"B,s0)]}'

assert jcof.loads(dumped) == example
# Returns nothing; True

📰 Changelog

The changelog is at CHANGELOG.md.

📜 License

pyjcof is licensed under GNU General Public License 3.0 or later.

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

jcof-1.0.0.tar.gz (21.5 kB view hashes)

Uploaded Source

Built Distribution

jcof-1.0.0-py3-none-any.whl (21.2 kB view hashes)

Uploaded Python 3

Supported by

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