Pretty Printing
Zamiell opened this issue · 2 comments
Zamiell commented
Hello, and thanks for the library.
With normal JSON.stringify
, I can create pretty output like so:
console.log(JSON.stringify(request, undefined, 2));
I would like to emulate this behavior, but with superjson.
I imagine that the API could be changed from:
static stringify: (object: SuperJSONValue) => string;
To something like:
class StringifyOptions {
pretty = false;
}
static stringify: (object: SuperJSONValue, options = new StringifyOptions()) => string;
Or, more simply, but less flexible for future additions:
static stringify: (object: SuperJSONValue, pretty = false) => string;
Skn0tt commented
Hi @Zamiell! Pretty-Printing is out-of-scope for SuperJSON. If you want to prettify your output, you could do the following:
JSON.stringify(SuperJSON.serialize(request), undefined, 2)
Does that solve your problem?
Zamiell commented
Ok. I'll close this issue then, thank you for the quick response.