Json
Utility functions for working with JSON (with support for bigint
).
Examples
Below are some examples demonstrating common usages of the Json
module:
Stringifying JSON
JSON values can be stringified (with bigint
support) using Json.stringify
:
import { Json } from 'ox'
const json = Json.stringify({
foo: 'bar',
baz: 69420694206942069420694206942069420694206942069420n,
})
'{"foo":"bar","baz":69420694206942069420694206942069420694206942069420}'
Parsing JSON
JSON values can be parsed (with bigint
support) using Json.parse
:
import { Json } from 'ox'
const value = Json.parse('{"foo":"bar","baz":69420694206942069420694206942069420694206942069420}')
{ foo: 'bar', baz: 69420694206942069420694206942069420694206942069420n }
Functions
Name | Description |
---|---|
Json.parse | Parses a JSON string, with support for bigint . |
Json.stringify | Stringifies a value to its JSON representation, with support for bigint . |