encodeWire static method

Object? encodeWire(
  1. Object? value
)

The form in which value crosses to the coordinator: numbers, booleans and null as they are, anything else as a JSON string (shared between isolates, not copied), or the object itself when JSON cannot encode it. Exposed for tests and benchmarks.

Implementation

static Object? encodeWire(Object? value) {
  switch (value) {
    case null || num() || bool():
      return value;
    default:
      try {
        return jsonEncode(value);
      } on JsonUnsupportedObjectError {
        return value;
      }
  }
}