toFormattedString method

String toFormattedString({
  1. bool includeComments = true,
  2. bool json5 = true,
})

Returns a pretty-printed JSON or JSON5 string with 2-space indentation.

Implementation

String toFormattedString({bool includeComments = true, bool json5 = true}) {
  StringBuffer result = StringBuffer();
  _formatMap(
    buffer: result,
    container: this,
    includeComments: includeComments,
    json5: json5,
    jsonMap: _keyToValueMap,
    level: 0,
    registry: _commentRegistry,
  );
  return result.toString();
}