API reference / @evolu/common / Type / JsonValueFromString

Variable: JsonValueFromString

const JsonValueFromString: TransformType<
  Type<"String", string, string, StringError, string, StringError>,
  RecursiveType<
    UnionType<
      [
        Type<"String", string, string, StringError, string, StringError>,
        BrandType<
          Type<"Number", number, number, NumberError, number, NumberError>,
          "Finite",
          FiniteError,
          NumberError
        >,
        Type<"Boolean", boolean, boolean, BooleanError, boolean, BooleanError>,
        Type<"Null", null, null, NullError, null, NullError>,
        ArrayType<
          Type<
            "Recursive",
            JsonValue,
            JsonValueInput,
            JsonValueError,
            JsonValueInput,
            JsonValueError
          >
        >,
        RecordType<
          "String",
          string,
          string,
          StringError,
          string,
          StringError,
          Type<
            "Recursive",
            JsonValue,
            JsonValueInput,
            JsonValueError,
            JsonValueInput,
            JsonValueError
          >
        >,
      ]
    >
  >,
  JsonValueFromStringError
>;

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

Transform Type that parses a JSON into a JsonValue and serializes a JsonValue back into a JSON string.

Example

JsonValueFromString.from(`{"key":"value"}`); // -> ok({ key: "value" })
JsonValueFromString.to({ key: "value" }); // -> '{"key":"value"}'

Was this page helpful?