toJson method
Returns this value as JSON fields.
Implementations may reject invalid typed values with StateError; native Core validation and connection startup are separate operations.
Implementation
@override
JsonMap toJson() {
if (inbounds.isEmpty) {
throw StateError('Xray config must contain at least one inbound');
}
if (outbounds.isEmpty) {
throw StateError('Xray config must contain at least one outbound');
}
final json = <String, dynamic>{
'log': log.toJson(),
'inbounds': inbounds.map((inbound) => inbound.toJson()).toList(),
'outbounds': outbounds.map((outbound) => outbound.toJson()).toList(),
'routing': routing.toJson(),
};
return sanitizeXrayJson(json) as JsonMap;
}