Skip to main content

Function: prettyJSON()

prettyJSON(o): string

Defined in: base/common.ts:58

Converts a JSON value to a pretty-printed string.

If the input object has a toJSON method, it will be called first to get the serializable representation of the object.

Parameters

ParameterTypeDescription
oReadonlyJSONValueThe JSON value to pretty print

Returns

string

A formatted string representation of the input

Example

const obj = { foo: 'bar', baz: 42 };
console.log(prettyJSON(obj));
// Output:
// {
// "foo": "bar",
// "baz": 42
// }