Example usage for com.google.gson.internal LazilyParsedNumber longValue

List of usage examples for com.google.gson.internal LazilyParsedNumber longValue

Introduction

In this page you can find the example usage for com.google.gson.internal LazilyParsedNumber longValue.

Prototype

@Override
    public long longValue() 

Source Link

Usage

From source file:com.tsc9526.monalisa.tools.json.MelpJson.java

License:Open Source License

public static Object primitive(JsonPrimitive e) {
    if (e.isNumber()) {
        Number n = e.getAsNumber();
        if (n instanceof LazilyParsedNumber) {
            LazilyParsedNumber ln = (LazilyParsedNumber) n;
            String value = ln.toString();
            if (value.indexOf('.') >= 0) {
                return ln.doubleValue();
            } else {
                return ln.longValue();
            }/*from  ww  w  .  j  a va2  s. co  m*/
        } else {
            return n;
        }
    } else if (e.isBoolean()) {
        return e.getAsBoolean();
    } else {
        return e.getAsString();
    }
}