Function assertStringify

  • 5x faster JSON.stringify() function with type assertion.

    typia.json.assertStringify() is a combination function of assert and stringify. Therefore, it converts an input value to JSON (JavaScript Object Notation) string, with type assertion.

    In such reason, when input value is not matched with the type T, it throws an TypeGuardError or custom error generated by errorFactory. Otherwise, there's no problem on the input value, JSON string would be returned.

    For reference, with type assertion, it is even 5x times faster than the native JSON.stringify() function. So, just enjoy the safe and fast JSON conversion with confidence.

    Type Parameters

    • T

      Type of the input value

    Parameters

    • input: T

      A value to be asserted and converted

    • OptionalerrorFactory: ((props: TypeGuardError.IProps) => Error)

      Custom error factory. Default is TypeGuardError

    Returns string

    JSON string value

    Jeongho Nam - https://github.com/samchon

  • 5x faster JSON.stringify() function with type assertion.

    typia.json.assertStringify() is a combination function of assert and stringify. Therefore, it converts an input value to JSON (JavaScript Object Notation) string, with type assertion.

    In such reason, when input value is not matched with the type T, it throws an TypeGuardError or custom error generated by errorFactory. Otherwise, there's no problem on the input value, JSON string would be returned.

    For reference, with type assertion, it is even 5x times faster than the native JSON.stringify() function. So, just enjoy the safe and fast JSON conversion with confidence.

    Type Parameters

    • T

      Type of the input value

    Parameters

    • input: T

      A value to be asserted and converted

    • OptionalerrorFactory: ((props: TypeGuardError.IProps) => Error)

      Custom error factory. Default is TypeGuardError

    Returns unknown

    JSON string value

    Jeongho Nam - https://github.com/samchon