Code example for JsonArray

Methods: getsize

0
    @Override 
    public Bbox deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
        Bbox bbox = new Bbox();
        if (json instanceof JsonArray) {
            JsonArray array = (JsonArray)json;
            if (array.size() != 4) {
                throw new JsonParseException("Bbox must be of format [minX,minY,maxX,maxY]");
            } 
            // TODO check validity of bbox 
            bbox.setMinx(array.get(0).getAsDouble());
            bbox.setMiny(array.get(1).getAsDouble());
            bbox.setMaxx(array.get(2).getAsDouble());
            bbox.setMaxy(array.get(3).getAsDouble());
        } else { 
            throw new JsonParseException("Bbox must be JSON array");
        } 
        return bbox;
    } 
 
} 
Experience pair programming with AI  Get Codota for Java