Example usage for com.google.gson JsonElement getAsDouble

List of usage examples for com.google.gson JsonElement getAsDouble

Introduction

In this page you can find the example usage for com.google.gson JsonElement getAsDouble.

Prototype

public double getAsDouble() 

Source Link

Document

convenience method to get this element as a primitive double value.

Usage

From source file:vellum.jx.JMaps.java

License:Apache License

public static Object parsePrimitive(JsonElement element) {
    String string = element.toString();
    if (string.equals("true")) {
        return element.getAsBoolean();
    } else if (string.equals("false")) {
        return element.getAsBoolean();
    } else if (string.startsWith("\"")) {
        return element.getAsString();
    } else if (string.contains(".")) {
        return element.getAsDouble();
    } else if (string.matches("[0-9]*")) {
        return element.getAsLong();
    }//from  ww w .jav a 2  s.  com
    return element.getAsString();
}