detectIndent
detectIndent(
text):string|undefined
Defined in: stringify-json.ts:35
The indentation one level of nesting adds in a JSON document — the leading
whitespace (spaces or a tab) of the first line after the first one, less any
padding the root value’s own line starts with. undefined when there is
none, e.g. a minified or single-line document.
Raw newlines can’t occur inside a JSON string, so any line that starts with whitespace is structural indentation.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”string | undefined
Example
Section titled “Example”import { detectIndent } from "@theholocron/json-utils";
detectIndent('{\n\t"a": 1\n}'); // "\t"detectIndent('{"a":1}'); // undefined