writeJson static method

CappConsole writeJson(
  1. dynamic json, {
  2. bool pretty = false,
  3. CappColors color = CappColors.none,
  4. int indent = 4,
  5. String indantChar = ' ',
})

Implementation

static CappConsole writeJson(
  dynamic json, {
  bool pretty = false,
  CappColors color = CappColors.none,
  int indent = 4,
  String indantChar = ' ',
}) {
  if (pretty) {
    var encoder = JsonEncoder.withIndent(
      indantChar * indent,
      (object) {
        return object.toString();
      },
    ); // Indent with two spaces
    var res = encoder.convert(json);
    return write(res, color);
  } else {
    var res = jsonEncode(json);
    return write(res, color);
  }
}