toJson method
Wire form with stable key order (zap first — the envelope reads
top-down).
Implementation
@override
Map<String, Object?> toJson() => <String, Object?>{
'zap': zapProtocolVersion,
'type': type,
'id': id,
'ts': ts,
'code': code,
'message': message,
if (inReplyTo != null) 'inReplyTo': inReplyTo,
if (details != null && details!.isNotEmpty) 'details': details,
};