use of com.google.gson.GsonBuilder in project play-cookbook by spinscale.
the class ApiPlugin method onApplicationStart.
@Override
public void onApplicationStart() {
try {
List<ApplicationClass> applicationClasses = Play.classes.getAnnotatedClasses(XmlRootElement.class);
List<Class> classes = new ArrayList<Class>();
for (ApplicationClass applicationClass : applicationClasses) {
classes.add(applicationClass.javaClass);
}
jc = JAXBContext.newInstance(classes.toArray(new Class[] {}));
} catch (JAXBException e) {
Logger.error(e, "Problem initializing jaxb context: %s", e.getMessage());
}
gson = new GsonBuilder().create();
Logger.info("ApiPlugin loaded");
}
use of com.google.gson.GsonBuilder in project play-cookbook by spinscale.
the class ApiPlugin method onApplicationStart.
public void onApplicationStart() {
Logger.info("ApiPlugin loaded");
try {
List<ApplicationClass> applicationClasses = Play.classes.getAnnotatedClasses(XmlRootElement.class);
List<Class> classes = new ArrayList<Class>();
for (ApplicationClass applicationClass : applicationClasses) {
classes.add(applicationClass.javaClass);
}
jc = JAXBContext.newInstance(classes.toArray(new Class[] {}));
} catch (JAXBException e) {
Logger.error(e, "Problem initializing jaxb context: %s", e.getMessage());
}
gson = new GsonBuilder().create();
}
use of com.google.gson.GsonBuilder in project android-app by spark.
the class WebHelpers method initialize.
// should be called during Application.onCreate() to ensure availability
public static void initialize(Context ctx) {
if (!initialized) {
if (AppConfig.useStaging()) {
okHttpClient = disableTLSforStaging();
} else {
okHttpClient = new OkHttpClient();
}
gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
initialized = true;
}
}
use of com.google.gson.GsonBuilder in project spring-framework by spring-projects.
the class GsonFactoryBean method afterPropertiesSet.
@Override
public void afterPropertiesSet() {
GsonBuilder builder = (this.base64EncodeByteArrays ? GsonBuilderUtils.gsonBuilderWithBase64EncodedByteArrays() : new GsonBuilder());
if (this.serializeNulls) {
builder.serializeNulls();
}
if (this.prettyPrinting) {
builder.setPrettyPrinting();
}
if (this.disableHtmlEscaping) {
builder.disableHtmlEscaping();
}
if (this.dateFormatPattern != null) {
builder.setDateFormat(this.dateFormatPattern);
}
this.gson = builder.create();
}
use of com.google.gson.GsonBuilder in project jstorm by alibaba.
the class ZooKeeperDataViewTest method init.
@BeforeClass
public static void init() {
String CONFIG_PATH = System.getProperty("user.home") + CONFIG_FILE;
File file = new File(CONFIG_PATH);
if (file.exists() == false) {
SKIP = true;
return;
}
try {
zkobj = new Zookeeper();
System.getProperties().setProperty("storm.conf.file", CONFIG_PATH);
Map conf = Utils.readStormConfig();
zk = zkobj.mkClient(conf, (List<String>) conf.get(Config.STORM_ZOOKEEPER_SERVERS), conf.get(Config.STORM_ZOOKEEPER_PORT), (String) conf.get(Config.STORM_ZOOKEEPER_ROOT));
gson = new GsonBuilder().setPrettyPrinting().create();
} catch (Throwable e) {
e.printStackTrace();
SKIP = true;
}
}
Aggregations