Code example for JsonPrimitive

    public JsonElement serialize(Center src, Type typeOfSrc, JsonSerializationContext context) {
        JsonArray centerArray = new JsonArray();
        JsonPrimitive x = new JsonPrimitive(src.getX());
        JsonPrimitive y = new JsonPrimitive(src.getY());
        return centerArray;
    public Center deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
        Center center = new Center();
        if (json instanceof JsonArray) {
            JsonArray array = (JsonArray)json;
            if (array.size() != 2) {
                throw new JsonParseException("Center must be of format [x,y]");
            // TODO check validity of bbox 
Connect your IDE to all the code out there  Get Codota for Java