Skip to content

docs: add a toJson serialization example to the README - #28

Merged
cryo2010 merged 1 commit into
mainfrom
docs/tojson-example
Jul 25, 2026
Merged

cryo2010 merged 1 commit into
mainfrom
docs/tojson-example

Conversation

@cryo2010

Copy link
Copy Markdown
Owner

Adds a Serialization section right after the JSON Schema section, making an in/out pair. One three-field schema demonstrates everything that distinguishes toJson from std/json's %: the aliased field is written back under its JSON key, the timestamp() field becomes unix seconds again, and the mutated Fahrenheit value is inverted through the transform's back to Celsius on the wire. Also states the tryValidate == tryParse(toJson(v)) identity.

Snippet and its output comment are verified by compiling and running the assembled code (including a tryValidate round-trip check).

Shows toJson as parse's inverse in one schema: an aliased key written
back, a Time re-emitted as unix seconds, and a transform inverted via
back, plus the tryParse(toJson(v)) identity behind tryValidate. Output
comment verified against an actual run.
@cryo2010
cryo2010 merged commit 209416d into main Jul 25, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant