Implements deserializing multiline text to solve issue
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import com.google.gson.JsonDeserializer;
import com.google.gson.JsonParseException;
import org.terasology.assets.ResourceUrn;
private static final long serialVersionUID = -2255189133660408141L;
};
- private final Gson gson = new GsonBuilder().create();
+ private final JsonDeserializer<String> stringArraySerializer = (json, typeOfSrc, context) -> {
+ if (json.isJsonArray()) {
+ StringBuilder stringFromArray = new StringBuilder();
+ json.getAsJsonArray().forEach(o -> stringFromArray.append(o.getAsString()));
+ return stringFromArray.toString();
+ } else {
+ return json.getAsString();
+ }
+ };
+
+ private final Gson gson = new GsonBuilder().registerTypeAdapter(String.class, stringArraySerializer).create();
@Override
public PathMatcher getFileMatcher() {
