Crates.io | fog-human-json |
lib.rs | fog-human-json |
version | 0.2.1 |
source | src |
created_at | 2023-07-12 02:42:27.493736 |
updated_at | 2023-08-14 01:54:57.996509 |
description | Human-readable fog-pack data, through JSON. |
homepage | https://github.com/Cognoscan/fog-human-json |
repository | https://github.com/Cognoscan/fog-human-json |
max_upload_size | |
id | 914243 |
size | 58,425 |
This crate provides functions to go back and forth between fog-pack and JSON, making it relatively easy for users to view pretty-printed fog-pack values and edit them with existing JSON tooling. A common complaint with binary data formats like fog-pack is that reading them is painful, and lowering that pain with JSON is exactly what this crate is for.
This is not a crate for turning regular JSON into fog-pack data. It uses a number of special string prefixes to encode fog-pack types in JSON, which can interfere with arbitrary JSON-to-fog conversions.
So, what does this actually do for conversion? Well, it takes each fog-pack type
and either directly converts it to a corresponding JSON type, or it specially
encodes it in a string that starts with $fog-
. So a 32-bit floating point
value could be specifically encoded as $fog-F32: 1.23
. The full list of types
is:
$fog-
won't get caught by the parser.+/
, no padding used, padding is accepted when parsing).serde_json
will always use F64 for floating-point).That covers conversion between fog-pack Values and JSON values, but not Documents and Entries. Those are converted into JSON objects with the following key-value pairs:
$fog-Hash:HASH
with the schema.$fog-Identity:IDENTITY
with the signer's
Identity.When going from JSON to a Document or Entry, if there's a "signer" specified, it will attempt to pull a matching IdentityKey from a provided Vault and use that to reproduce the signature. If it can't, then the conversion will fail.