API Reference / @evolu/common / Type / Json

Variable: Json

const Json: BrandType<Type<"String", string, string, StringError, string, StringError>, "Json", JsonError, StringError>;

Defined in: packages/common/src/Type.ts:3493

JSON-string Type.

Example

const result = Json.from('{"key":"value"}'); // -> ok('{"key":"value"}')
const error = Json.from("invalid json"); // -> err({ type: "Json", value: "invalid json", message: "Unexpected token i in JSON at position 0" })

Was this page helpful?