Code example for JsonPrimitive

Methods: isBoolean

	    else if(json.isJsonPrimitive()) return handlePrimitive(json.getAsJsonPrimitive());
	    else if(json.isJsonArray()) return handleArray(json.getAsJsonArray(), context);
	    else return handleObject(json.getAsJsonObject(), context);
	  private Object handlePrimitive(JsonPrimitive json) {
	      return json.getAsBoolean();
	    else if(json.isString())
	      return json.getAsString();
	    else { 
	      BigDecimal bigDec = json.getAsBigDecimal();
	      // Find out if it is an int type 
	      try { 
	        try { return bigDec.intValueExact(); }
	        catch(ArithmeticException e) {}
	        return bigDec.longValue();
	      } catch(ArithmeticException e) {}
	      // Just return it as a double 
	      return bigDec.doubleValue();
Connect your IDE to all the code out there  Get Codota for Java