Header menu logo issie

JsonHelpers Module

Types

Type Description

JSONCanvasState

SavedCanvasUnknownWaveInfo<'T>

SavedInfo

Functions and values

Function or value Description

convStateToJC (compL, connL)

Full Usage: convStateToJC (compL, connL)

Parameters:
Returns: Component list * 'a

converts Component to JSONComponent.Component for saving as JSON. this conversion does not affect the JSON generated.

compL : Component list
connL : 'a
Returns: Component list * 'a

extraCoder

Full Usage: extraCoder

Returns: ExtraCoders
Returns: ExtraCoders

jsonStringToState jsonString

Full Usage: jsonStringToState jsonString

Parameters:
    jsonString : string

Returns: Result<SavedInfo, string>

NB tryParseNativeAs, not tryParseAs. Both are SimpleJson and both end in the same AST-to-value conversion; they differ only in how the AST is built. tryParseAs uses Fable.Parsimmon parser combinators over the whole file and measured ~8x slower than the native JSON.parse variant - 59ms against 7ms on a 108KB sheet - and this function tries up to three types in turn, so it paid that cost more than once per sheet loaded. The two were checked to agree on every demo sheet, for each of the three types below.

jsonString : string
Returns: Result<SavedInfo, string>

stateToJsonString (cState, waveInfo, sheetInfo)

Full Usage: stateToJsonString (cState, waveInfo, sheetInfo)

Parameters:
Returns: Result<string, string>

Code to convert a CanvasState to a JSON string, does not work for bigints (I think). A serialisation failure is an Error: it must never be written to the sheet's .dgm file, which would overwrite the sheet with garbage.

cState : CanvasState
waveInfo : SavedWaveInfo option
sheetInfo : SheetInfo option
Returns: Result<string, string>

stateToJsonStringExperimental (cState, waveInfo, sheetInfo)

Full Usage: stateToJsonStringExperimental (cState, waveInfo, sheetInfo)

Parameters:
Returns: Result<string, string>

Code to convert a CanvasState to a JSON string, allowing bigints

cState : CanvasState
waveInfo : SavedWaveInfo option
sheetInfo : SheetInfo option
Returns: Result<string, string>

Type something to start searching.