Serialise to the wire format.
Map<String, Object?> toJson() => <String, Object?>{ 'prefix': prefix, 'routeType': routeType, 'stack': stack.toJson(), };