encode static method

dynamic encode(
  1. dynamic data
)

Implementation

static dynamic encode(dynamic data) {
  switch (data) {
    case NRouterJsonTransfrom value:
      return value.toJson();
    case Enum value:
      return value.index;
    case Map map:
      return encodeMap(map);
    case List list:
      return encodeList(list);
    default:
      final fn = get(data.runtimeType);
      if (fn != null) {
        data = fn.$1?.call(data) ?? data.toJson();
      }
      return data;
  }
}