Skip to content

JSON

JSON serialization and parsing. JSON.parse returns Result instead of throwing.

FunctionSignatureDescription
JSON.stringifyT -> stringSerialize a value to JSON
JSON.parsestring -> Result<T, ParseError>Parse JSON string safely
const json = user |> JSON.stringify
// '{"name":"Alice","age":30}'
const parsed = json |> JSON.parse
// Ok({name: "Alice", age: 30})
match JSON.parse(input) {
Ok(data) -> process(data),
Err(e) -> Console.error(e),
}