YTsaurus YSON

0.4.10 · active · verified Sun Apr 12

YTsaurus YSON (version 0.4.10) provides high-performance C++ bindings for YSON (Yandex Serialization Object Notation), enabling fast serialization and deserialization of YSON data. It is a sub-package of the larger `ytsaurus-python` project, specifically focused on YSON processing. Releases are tied to the `ytsaurus-python` project, with regular updates that reflect changes in the broader YTsaurus ecosystem.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates basic serialization (`dumps`) and deserialization (`loads`) of YSON data using `ytsaurus-yson`. Note that `loads` expects bytes and `dumps` produces bytes, consistent with the binary nature of YSON. It also shows how YSON attributes are handled.

from ytsaurus_yson import loads, dumps

# Deserialize YSON bytes to Python object
y_string_bytes = b'{key="value";number=123;list=[a;b;c;];}'
data = loads(y_string_bytes)
print(f"Deserialized: {data} (Type: {type(data)})\n")

# Serialize Python object to YSON bytes
python_object = {'name': 'Alice', 'age': 30, 'hobbies': ['reading', 'coding']}
yson_bytes = dumps(python_object)
print(f"Serialized: {yson_bytes} (Type: {type(yson_bytes)})\n")

# Demonstrate basic usage with YSON attributes (advanced)
yson_with_attrs = b'<"version"="1.0">{data="payload"}'
loaded_with_attrs = loads(yson_with_attrs)
print(f"Data with attributes: {loaded_with_attrs.value}, Attributes: {loaded_with_attrs.attributes}")

view raw JSON →