/// Created by Haoyi on 2022/4/27

part of "converts.dart";

class JoinedStringListConvert implements JsonConverter<List<String>, String> {
  const JoinedStringListConvert();

  @override
  List<String> fromJson(String joinedStr) {
    if (joinedStr.isEmpty) {
      return <String>[];
    }
    final segments = joinedStr.split('|');
    return segments.where((segment) => segment.isNotEmpty).toList();
  }

  @override
  String toJson(List<String> data) {
    return data.join('|');
  }
}
