toJson function

String toJson (dynamic object, { bool parseString: false, dynamic depth, dynamic exclude })

Serializes the object to a JSON string.


depth : determines how deep is going to be the serialization and avoids stack overflow produced by cyclical object references. exclude : exclude some attributes. It could be String, Map, or List


String toJson(object, {bool parseString: false, depth, exclude}) {
//  _serLog.fine("Start serializing");

  if (!parseString && object is String) return object;

  var result = json.encode(objectToSerializable(object, depth: depth, exclude: exclude));


  return result;