Code example for JsonObject

Methods: getAsJsonArraygetAsJsonObjectgetAsJsonPrimitive

0
 
    private JsonObject getJsonObjectOrNull(JsonObject object, String index) {
        if (object == null)
            return null; 
        else 
            return object.getAsJsonObject(index);
    } 
 
    private JsonArray getJsonArrayOrNull(JsonObject object, String index) {
        if (object == null)
            return null; 
        else 
            return object.getAsJsonArray(index);
    } 
 
    private double getJsonDoubleOrNull(JsonObject object, String index) {
        if (object == null)
            return 0; 
        else 
            return object.getAsJsonPrimitive(index).getAsDouble();
    } 
 
    private String getJsonStringOrNull(JsonObject object, String index) {
        if (object == null)
            return null; 
        else 
            return object.getAsJsonPrimitive(index).getAsString();
    } 
 
    private GeocodeAddress parseToGeocodeAddress(JsonElement address) throws JsonParseException {
        GeocodeAddress result = new GeocodeAddress();
        JsonObject addressObject = address.getAsJsonObject();
Experience pair programming with AI  Get Codota for Java