jsonToString function

String jsonToString(
  1. Object json
)

Calls jsonEncode but throws an Exception if the input is unsupported.

Implementation

String jsonToString(Object json) {
  try {
    if (jsonEncode(json) case var result when result != "null") ////
      return result;
    throw FormatException("jsonToString: unexpected \"null\" result", json);
    // ignore: avoid_catching_errors
  } on JsonUnsupportedObjectError catch (x) {
    throw FormatException("jsonToString: $x", json);
  }
}