Function toJson

  • Converts the given data to a JSON string.

    Type Parameters

    • T

      The type of the data to be converted to JSON.

    Parameters

    • data: T

      The data to be converted to JSON.

    • pretty: boolean = false

      Optional parameter that determines whether the resulting JSON string should be pretty-printed. Default is false.

    Returns string

    The JSON string representation of the given data.

    Example

    toJson({ name: 'John', age: 30 }, true);;
    //=> "{\n "name": "John",\n "age": 30\n}"

Generated using TypeDoc