Crates.io | litl |
lib.rs | litl |
version | 0.6.0 |
source | src |
created_at | 2022-08-02 13:28:09.21144 |
updated_at | 2023-02-28 18:50:38.102199 |
description | A JSON dialect with support for tagged binary data |
homepage | |
repository | |
max_upload_size | |
id | 637330 |
size | 42,287 |
"Little term language"
Self-describing, human readable encoding format for structured data.
Litl is a dialect of JSON, more precisely it is
Litl shares the following types of values with JSON:
true
, false
and null
42
, 2.8299e-10
"Hello"
, "👾"
["a","b","c",5]
{"a":1,"b":2,"c":"d"}
These ubsequently will be referred to as "JSON values"
To that, it adds only two concepts:
"h3znn4pjays7u46h"
"hash_hbk5tfu4p3jncen"
Raw binary data MUST be encoded as z-base32 in a JSON string, with the prefix "h"
.
All strings of this format (prefix + valid Base58) MUST be considered binary data.
Since raw binary data is encoded as a JSON string, it can be used as a key in dictionaries and MUST be encoded in the same way strings are encoded according to the JCS.
Binary data in Litl can be tagged to annotate it with additional type information. This can be used to represent more precise types, newtype-style wrapping or to discriminate between variants of enums.
Tags are strings consisting of arbitrary UTF-8 characters, but MUST NOT contain underscores "_"
.
Multi-word tags SHOULD be written in camelCase.
Raw binary data MUST be tagged by prefixing the tag to the raw binary string representation:
tag_hgrodomjqb5bcse
Tagged binary data can be tagged with additional tags. Additional tags MUST be specified by prefixing each tag, separating tags by underscores:
outerTag_innerTag_z9jr402fnnsldkn
All strings of these formats (underscore-separated tags + _h
prefix + valid z-bae32) MUST be considered tagged binary data.
Since tagged binary data is encoded as a JSON string, it can be used as a key in dictionaries.
To conform to canonical Litl encoding, values MUST be encoded according to the JSON Canonicalization Scheme ("JCS", RFC 8785), which defines a canonical encoding for numbers, strings and deterministic ordering of key-value pairs in objects.
To conform to canonical Litl encoding, raw and tagged binary Data MUST be encoded in the same way strings are encoded according to the JCS.