mirror of
https://github.com/2dust/v2rayNG.git
synced 2026-11-03 19:54:30 +00:00
23 lines
564 B
Java
23 lines
564 B
Java
package me.dozen.dpreference;
|
|
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
|
import java.lang.reflect.Type;
|
|
import java.util.LinkedHashSet;
|
|
import java.util.Set;
|
|
|
|
public class StringSetConverter {
|
|
private static final Gson gson = new Gson();
|
|
|
|
public static String encode(Set<String> src) {
|
|
return gson.toJson(src);
|
|
}
|
|
|
|
public static LinkedHashSet<String> decode(String json) {
|
|
Type setType = new TypeToken<LinkedHashSet<String>>() {
|
|
}.getType();
|
|
return gson.fromJson(json, setType);
|
|
}
|
|
}
|