jsonurl-py

Python implementation of jsonurl, an alternative format for JSON data model


License
MIT
Install
pip install jsonurl-py==0.4.0

Documentation

JSON->URL PYthon implementation

About

This is a python implementation of jsonurl, an alternative text format which encodes the same data model in a way that is more suitable for use in URLs.

See https://jsonurl.org/ and especially https://github.com/jsonurl/specification/

The following optional features are supported:

  • 2.9.1 Implied Arrays
  • 2.9.2 Implied Objects
  • 2.9.5 Distinction between empty object and array
  • 2.9.6 AQF - Address Bar Query String Friendly

The following optional features are not yet supported:

  • 2.9.3 WFU - x-www-form-urlencoded Arrays and Objects
  • 2.9.4 Implied Object Missing Values

Installation

pip install jsonurl-py

The package name is jsonurl_py to avoid confusion with an unrelated jsonurl package on pypi which implements an unrelated syntax. In theory you can install and import both packages without having them interfere with each other.

The project name uses a dash in the name for consistency with the existing jsonurl-js and jsonurl-java implementations.

Usage

import jsonurl_py as jsonurl

assert jsonurl.loads('(a:1,b:c)') == {'a': 1, 'b': 'c'}
assert jsonurl.dumps(dict(a=[1,2])) == '(a:(1,2))'

Command Line Interface

The package includes a command line interface for converting between jsonurl and standard json:

$ echo "(a:b)" | jsonurl-py load
{"a": "b"}
$ echo '{"a":"b"}' | jsonurl-py dump
(a:b)

It is also possible to run the executable directly via pipx:

$ echo '(a:b)' | pipx run jsonurl-py load
{"a": "b"}

Documentation

Published on github pages.

Can be built locally using tox -e docs

Testing

Tests run via github actions.

Code coverage for main branch is published on github pages.