toJsonString method
Returns a JSON string representation of the BaseModel.
If the model cannot be encoded, this returns a JSON object with the
error message under the key "e" instead of throwing, because
toString calls it and a toString that throws breaks logging and
debugging.
Implementation
String toJsonString() {
try {
final encoder = const JsonEncoder.withIndent(' ');
return encoder.convert(sortedJson());
} catch (e) {
return jsonEncode({'e': '$e'});
}
}