com.testvagrant.optimus.commons.filehandlers.GsonParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of optimus-lite Show documentation
Show all versions of optimus-lite Show documentation
Optimus Lite API to manage test devices and create appium driver based on platform
package com.testvagrant.optimus.commons.filehandlers;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.Map;
public class GsonParser {
private final Gson gson;
private GsonParser() {
this.gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create();
}
public static GsonParser toInstance() {
return new GsonParser();
}
public String serialize(T object) {
return gson.toJson(object);
}
public T deserialize(FileReader reader, Class tClass) {
return gson.fromJson(reader, tClass);
}
public T deserialize(String json, Class tClass) {
return gson.fromJson(json, tClass);
}
public T deserialize(InputStreamReader streamReader, Class tClass) {
return gson.fromJson(streamReader, tClass);
}
public T deserialize(JsonElement jsonElement, Class tClass) {
return gson.fromJson(jsonElement, tClass);
}
public Map deserialize(String json, Type tType) {
return gson.fromJson(json, tType);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy