JSONMessageCodec class

MessageCodec with UTF-8 encoded JSON messages.

Supported messages are acyclic values of these forms:

On Android, messages are decoded using the org.json library. On iOS, messages are decoded using the NSJSONSerialization library. In both cases, the use of top-level simple messages (null, bool, num, and String) is supported (by the Flutter SDK). The decoded value will be null/nil for null, and identical to what would result from decoding a singleton JSON array with a Boolean, number, or string value, and then extracting its single element.

The type returned from decodeMessage is dynamic (not Object?), which means no type checking is performed on its return value. It is strongly recommended that the return value be immediately cast to a known type to prevent runtime errors due to typos that the type checker could otherwise catch.

Implemented types

Constructors

JSONMessageCodec()
Creates a MessageCodec with UTF-8 encoded JSON messages.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

decodeMessage(ByteData? message) → dynamic
Decodes the specified message from binary.
override
encodeMessage(Object? message) ByteData?
Encodes the specified message in binary.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited