Header menu logo issie

SimpleJsonDotNet Module

Deserialises the JSON encoding used by Fable.SimpleJson, which is what the app writes into every .dgm file. Without this, nothing running under .NET can open a sheet, because Thoth.Json.Net - what `Helpers.jsonStringToState` otherwise uses there - cannot read what the app wrote. The two encodings disagree about unions (Thoth writes an array; SimpleJson writes a bare string for a nullary case and a single-property object otherwise), about options (Thoth wraps the value; SimpleJson writes the value itself, or null) and about maps with structural keys (SimpleJson writes an array of pairs). Rather than enumerate the `SavedInfo` schema - which would mean every `ComponentType` case, and a new one every time a component is added - this walks the target type by reflection, so it covers whatever the types say. Fable never sees any of this: under Fable the app calls SimpleJson itself, and Newtonsoft is not available. Under .NET it reaches this project transitively through Thoth.Json.Net.

Functions and values

Function or value Description

tryDeserialise json

Full Usage: tryDeserialise json

Parameters:
    json : string

Returns: Result<'T, string>

Read json as a 'T, or say why it is not one. Failure is an ordinary outcome here, not a bug: jsonStringToState works out which of three formats a sheet file is in by trying each in turn.

json : string
Returns: Result<'T, string>

Type something to start searching.