Code example for JsonPrimitive

Methods: isNumber

0
    } 
 
    private String keyToString(JsonElement keyElement) {
      if (keyElement.isJsonPrimitive()) {
        JsonPrimitive primitive = keyElement.getAsJsonPrimitive();
        if (primitive.isNumber()) {
          return String.valueOf(primitive.getAsNumber());
        } else if (primitive.isBoolean()) {
          return Boolean.toString(primitive.getAsBoolean());
        } else if (primitive.isString()) {
          return primitive.getAsString();
        } else { 
          throw new AssertionError();
        } 
      } else if (keyElement.isJsonNull()) {
        return "null"; 
      } else { 
        throw new AssertionError();
      } 
    } 
Connect your IDE to all the code out there  Get Codota for Java