class BboxAdapter implements JsonSerializer<Bbox>, JsonDeserializer<Bbox> {

	@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) {
				double minX = array.get(0).getAsDouble();
				double minY = array.get(1).getAsDouble();
				double maxX = array.get(2).getAsDouble();
				double maxY = array.get(3).getAsDouble();
				bbox.setBbox(minX, minY, maxX, maxY);
			} else if (array.size() == 0) {
				bbox.setBbox(null);
			} else {
				throw new JsonParseException("Bbox must be of format [minX,minY,maxX,maxY]");
			}
		} else {
			throw new JsonParseException("Bbox must be JSON array");
		}
		return bbox;
	}

}