Search in sources :

Example 1 with ResultGSONAdapter

use of org.structr.rest.adapter.ResultGSONAdapter in project structr by structr.

the class ThreadLocalGson method initialValue.

@Override
protected Gson initialValue() {
    final ResultGSONAdapter resultGsonAdapter = new ResultGSONAdapter(propertyView, outputNestingDepth);
    final JsonInputGSONAdapter jsonInputAdapter = new JsonInputGSONAdapter();
    // create GSON serializer
    final GsonBuilder gsonBuilder = new GsonBuilder().setPrettyPrinting().serializeNulls().registerTypeHierarchyAdapter(FrameworkException.class, new FrameworkExceptionGSONAdapter()).registerTypeAdapter(IJsonInput.class, jsonInputAdapter).registerTypeAdapter(Result.class, resultGsonAdapter);
    final boolean lenient = Settings.JsonLenient.getValue();
    if (lenient) {
        // Serializes NaN, -Infinity, Infinity, see http://code.google.com/p/google-gson/issues/detail?id=378
        gsonBuilder.serializeSpecialFloatingPointValues();
    }
    return gsonBuilder.create();
}
Also used : ResultGSONAdapter(org.structr.rest.adapter.ResultGSONAdapter) GsonBuilder(com.google.gson.GsonBuilder) JsonInputGSONAdapter(org.structr.core.rest.JsonInputGSONAdapter) FrameworkExceptionGSONAdapter(org.structr.rest.adapter.FrameworkExceptionGSONAdapter) IJsonInput(org.structr.core.IJsonInput)

Aggregations

GsonBuilder (com.google.gson.GsonBuilder)1 IJsonInput (org.structr.core.IJsonInput)1 JsonInputGSONAdapter (org.structr.core.rest.JsonInputGSONAdapter)1 FrameworkExceptionGSONAdapter (org.structr.rest.adapter.FrameworkExceptionGSONAdapter)1 ResultGSONAdapter (org.structr.rest.adapter.ResultGSONAdapter)1