Python Rison Encoder/Decoder

0.2.1 · maintenance · verified Thu Apr 09

"prison" is a Python library providing an encoder and decoder for the Rison data serialization format. Rison (Recursive object notation) is a compact, URL-safe data format designed for representing simple data structures, often used in URLs. The current version is 0.2.1. The library is largely feature-complete for the Rison specification and has a low release cadence.

Warnings

Install

Imports

Quickstart

Demonstrates encoding a Python dictionary to a Rison string and then decoding it back. Rison is optimized for URL-safe representation of simple data structures.

import prison

data = {'name': 'Alice', 'age': 30, 'tags': ['dev', 'python']}

# Encode Python dict to Rison string
rison_string = prison.dumps(data)
print(f"Encoded Rison: {rison_string}")
# Expected: (name:Alice,age:30,tags:!(dev,python))

# Decode Rison string back to Python dict
decoded_data = prison.loads(rison_string)
print(f"Decoded data: {decoded_data}")
# Expected: {'name': 'Alice', 'age': 30, 'tags': ['dev', 'python']}

view raw JSON →