mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-16 23:24:24 +00:00
craft-gridcraft-format
GridCraft's native workbook file is one pretty-printed UTF-8 JSON object, with a two-space indent
and no newline at the end. It is saved as .json, or as .scjson by older builds.
The workbook is a type parameter. GridCraft owns the model, and after a read it rebuilds the model's indexes, drops cells outside the grid and reads the macros. This crate owns the bytes:
EXTENSIONSandis_extensionname the format.read(bytes)reads a workbook. A failure reads as "not a GridCraft JSON workbook: …".write(workbook)writes one withserde_json's pretty printer.write_with_kept(workbook, field, kept)appends entries that a newer version wrote, and this build kept without reading, to the top-level listfield, as the file held them. With nothing kept, the output is exactlywrite's. Otherwise the workbook goes through aserde_json::Valuefirst, so its object keys come out in map order, as GridCraft has always written them.
There is no unsafe and no panics, and it builds for wasm32-unknown-unknown.