format static method

String format(
  1. dynamic data, {
  2. int deep = 0,
  3. String indentation = " ",
  4. String key = "",
})

Implementation

static String format(
  dynamic data, {
  int deep = 0,
  String indentation = "  ",
  String key = "",
}) {
  try {
    if (data is String) {
      data = jsonDecode(data);
    }
    StringBuffer buffer = StringBuffer();
    //解析List
    if (data is List) {
      buffer.write(_parseList(data));
    } else if (data is Map) {
      //解析map
      buffer.write(_parseMap(data, count: deep, indentation: indentation));
    }
    return buffer.toString();
  } catch (e) {
    print(e);
  }
  return "";
}