kim-edn

1.4.1 · active · verified Fri Apr 17

kim-edn is a Python library providing an encoder and decoder for the EDN (Extensible Data Notation) format. It aims to offer a robust and efficient way to serialize and deserialize EDN data structures in Python. The current version is 1.4.1, and releases typically focus on packaging improvements, dependency updates, and minor fixes.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `kim-edn` to deserialize an EDN string into a Python dictionary and then serialize a Python dictionary back into an EDN string. It covers basic keyword mapping and data structure conversion.

from kim_edn import loads, dumps

# Example EDN string with a keyword and integer value
edn_string = '{:a 1}'

# Deserialize the EDN string to a Python dictionary
python_dict = loads(edn_string)
print(f"Deserialized: {python_dict} (type: {type(python_dict)})\n")

# Modify the dictionary (EDN keywords become Python keywords for keys)
python_dict[':b'] = "hello"

# Serialize the Python dictionary back to an EDN string
new_edn_string = dumps(python_dict)
print(f"Serialized: {new_edn_string}")

# Example with a list and map
complex_edn = '[1 2 {:c "test"}]'
complex_python = loads(complex_edn)
print(f"\nComplex Deserialized: {complex_python}")

view raw JSON →