Using Application Data
Build a document with owned JSON handles, save it atomically through a Unicode path, reload it, and verify the exact bytes with SHA-256.
root=CreateJsonObject() nameValue=CreateJsonString("Café 世界") JsonObjectSet root,"name",nameValue FreeJson nameValue If SaveJsonAtomic(root,"projects\世界\scene.json",2)=0 RuntimeError FilesystemError() EndIf loaded=LoadJson("projects\世界\scene.json") If loaded=0 Then RuntimeError JsonError() Print Sha256File("projects\世界\scene.json") FreeJson loaded FreeJson root
Keep one clear owner for every JSON handle. Use CopyJson when another part of the program needs an independent lifetime, and free short-lived constructor handles immediately after setting or appending them.
UUID text is canonical lowercase text. Use UUID_BYTES_RFC for network/display order and UUID_BYTES_WINDOWS only when interoperating with the mixed-endian Windows GUID or .NET Guid.ToByteArray() layout.
When importing legacy text, use DecodeText with an explicit code page such as TEXT_WINDOWS_1252. Keep path Strings as UTF-8; text codecs do not change the active path policy.
SHA-256 hashes exact stored bytes. It is suitable for integrity and identity checks, but raw SHA-256 does not authenticate data and is not a password-storage API.
Atomic writes flush the completed sibling file and request write-through publication before reporting success. They provide an old-or-new single-file contract on supported local Windows filesystems, not a multi-file transaction or protection from faulty storage hardware and remote filesystem behavior. Replacement publishes the sibling file's metadata; it does not promise to preserve arbitrary destination attributes or ACL metadata.
For background indexing, let each Worker Function load, inspect, and free its own JSON handles. Return only a summary Bank, check cancellation through ordinary worker safe points, and apply results on the main thread after checking the Job tag or generation. Random UUID creation and all writes are main-thread-only.