Transforms this instance into a JSON object.
Map<String,dynamic> toJSON() { return { 'type': runtimeType.toString(), 'from': from, 'to': to, 'cost': cost }; }