mcap/modules/jaison/readme.md
Musa Mahmood 811c096dd0 [0.0.8] Import: any folder of screenshots and photos into the library, a folder for each source
- Import window (and -import SOURCE DEST): every image under a folder (PNG, JPEG, HEIC, AVIF, WebP,
  GIF, BMP, TIFF, camera RAW) becomes an .mcap holding the file as it was, a preview turned by its
  EXIF orientation, and metadata.json and import.json Capture Text (date from EXIF, the file name or
  its time; file name as title; camera as app). .snagx files become the same .mcap SnagitConverter
  makes. Duplicates across the whole library are skipped by a hash index (.import-index); videos
  and sidecars are skipped; source files are only read.
- modules/Image_Decode: stb_image, then WIC for everything else; EXIF; orientation; previews.
  tools/image_probe.jai shows what it reads.
- modules/Snagx (and modules/jaison), copied from SnagitConverter.
- The library is a folder of folders: recursive scan, a folder filter, and a folder: search prefix.
- OCR, the viewer and ocr-bench decode any image format, turned the right way up.
- Rename D:\SnagitIndex to D:\McapIndex.
2026-10-09 08:15:12 +01:00

2.0 KiB
Raw Permalink Blame History

JSON serialization / deserialization module for Jai

This module offers two interfaces:

  • one uses a "generic tree" built from JSON_Value
  • the other is a typed version that serializes / deserializes your custom data structures.

The generic JSON_Value graphs are a pain to consume and even worse to produce by hand. But they allow you to parse any JSON, even if you don’t know the structure (or can’t reproduce it in Jai because it varies).

The typed interface is what you want for most cases.

Parsing / Deserialization

Parsing is as simple as:

// Typed version:
success, result := json_parse_string(json_str, Your_Type_To_Parse_Into);
// … or if you want to get a generic structure back:
success, result := json_parse_string(json_str);

There are also a convenience functions for parsing if the JSON data is in a file:

success, result := json_parse_file(json_filename, Your_Type_To_Parse_Into);
// … or
success, result := json_parse_file(json_filename);

See typed.jai and generic.jai for details and additional options.

Mixed typed and generic data

If you don’t know the structure of some subfield of your Your_Type_To_Parse_Into structure, but still want to get these values from the JSON data, you can declare these fields as the generic type JSON_Value or *JSON_Value and the generic parse function will take over at that point:

Your_Type_To_Parse_Into :: struct {
	name: string;
	age: int;
	something_we_dont_know_much_about: *JSON_Value; // Whatever structure hides in the JSON, it will be parsed into JSON_Value.
}

Printing / Serialization

Generating a string works the same for both interfaces:

json_str := json_write_string(my_value);

where my_value is either a JSON_Value or any other data structure.

See module.jai for details and additional parameters.

Dependencies

This module uses the unicode_utils module, which is included as a submodule.