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