Example usage for com.google.gson.internal.bind TypeAdapters BOOLEAN

List of usage examples for com.google.gson.internal.bind TypeAdapters BOOLEAN

Introduction

In this page you can find the example usage for com.google.gson.internal.bind TypeAdapters BOOLEAN.

Prototype

TypeAdapter BOOLEAN

To view the source code for com.google.gson.internal.bind TypeAdapters BOOLEAN.

Click Source Link

Usage

From source file:com.flipkart.batching.gson.adapters.BatchingTypeAdapters.java

License:Open Source License

private static void write(Gson gson, JsonWriter out, @Nullable Object value) throws IOException {
    if (value == null) {
        out.nullValue();/*from  w ww  . jav  a2 s.c o m*/
    } else if (value instanceof JSONObject) {
        getJSONObjectTypeAdapter(gson).write(out, (JSONObject) value);
    } else if (value instanceof JSONArray) {
        getJSONArrayTypeAdapter(gson).write(out, (JSONArray) value);
    } else if (value instanceof String) {
        TypeAdapters.STRING.write(out, (String) value);
    } else if (value instanceof Number) {
        TypeAdapters.NUMBER.write(out, (Number) value);
    } else if (value instanceof Boolean) {
        TypeAdapters.BOOLEAN.write(out, (Boolean) value);
    } else {
        gson.toJson(value, value.getClass(), out);
    }
}