RouterRule.fromJson constructor

RouterRule.fromJson(
  1. Object? json
)

Implementation

factory RouterRule.fromJson(Object? json) {
  final map = asJsonMap(json, 'router rule');
  return RouterRule(
    ruleTag: map['ruleTag'] as String?,
    outboundTag: map['outboundTag'] as String?,
    balancerTag: map['balancerTag'] as String?,
    domain: map['domain'] == null
        ? null
        : XrayStringList.fromJson(map['domain']),
    domains: map['domains'] == null
        ? null
        : XrayStringList.fromJson(map['domains']),
    ip: map['ip'] == null ? null : XrayStringList.fromJson(map['ip']),
    port: map['port'] == null ? null : XrayPortList.fromJson(map['port']),
    network: map['network'] == null
        ? null
        : XrayNetworkList.fromJson(map['network']),
    sourceIP: map['sourceIP'] == null
        ? null
        : XrayStringList.fromJson(map['sourceIP']),
    source: map['source'] == null
        ? null
        : XrayStringList.fromJson(map['source']),
    sourcePort: map['sourcePort'] == null
        ? null
        : XrayPortList.fromJson(map['sourcePort']),
    user: map['user'] == null ? null : XrayStringList.fromJson(map['user']),
    vlessRoute: map['vlessRoute'] == null
        ? null
        : XrayPortList.fromJson(map['vlessRoute']),
    inboundTag: map['inboundTag'] == null
        ? null
        : XrayStringList.fromJson(map['inboundTag']),
    protocols: map['protocol'] == null
        ? null
        : XrayStringList.fromJson(map['protocol']),
    attributes: (map['attrs'] as Map?)?.cast<String, String>(),
    localIP: map['localIP'] == null
        ? null
        : XrayStringList.fromJson(map['localIP']),
    localPort: map['localPort'] == null
        ? null
        : XrayPortList.fromJson(map['localPort']),
    process: map['process'] == null
        ? null
        : XrayStringList.fromJson(map['process']),
    webhook: map['webhook'] == null
        ? null
        : WebhookRuleConfig.fromJson(map['webhook']),
  );
}