toJSON method

String toJSON({
  1. Object? toEncodable(
    1. Object? nonEncodable
    )?,
})

Converts this map into a JSON string.

Use optional parameter toEncodable to convert types that are not a number, boolean, string, null, list or a map with string keys.

See jsonEncode.

Example:

{'a': 1, 'b': 2}.toJSON(); // '''{'a':1,'b':2}'''

Implementation

String toJSON({Object? Function(Object? nonEncodable)? toEncodable}) {
  return jsonEncode(this, toEncodable: toEncodable);
}