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

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

Introduction

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

Prototype

TypeAdapter JSON_ELEMENT

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

Click Source Link

Usage

From source file:melnorme.lang.utils.gson.JsonParserX.java

License:Open Source License

public JsonElement parse(JsonReader reader) throws IOException, JsonSyntaxExceptionX {
    // Based on GSON 2.2.4 code of Streams.parse(json);

    try {/*w  w  w  .  ja  v a 2 s . c o m*/
        return TypeAdapters.JSON_ELEMENT.read(reader);
    } catch (MalformedJsonException e) {
        throw new JsonSyntaxExceptionX(e);
    } catch (NumberFormatException e) {
        throw new JsonSyntaxExceptionX(e);
    } catch (JsonParseException e) {
        // I don't think JsonParseException is ever thrown from code above, 
        // not with normal JsonReader at least (a subclass might though). 
        // So just in case, sanitize it:
        throw new JsonSyntaxExceptionX(e.getCause());
    }
}

From source file:org.jclouds.json.internal.NullHackJsonLiteralAdapter.java

License:Apache License

@Override
public L read(JsonReader reader) throws IOException {
    return createJsonLiteralFromRawJson(TypeAdapters.JSON_ELEMENT.read(reader).toString());
}