@Override public void write(Json json, EnumOrderedSet object, Class knownType) { if(object == null) { json.writeValue(null); return; } json.writeObjectStart(); if(!object.isEmpty()) { json.writeValue("c", object.first().getClass().getName()); json.writeValue("i", object.first(), null); int sz = object.size(); Object[] r = new Object[sz - 1]; for (int i = 1, p = 0; i < sz; i++) { r[p++] = object.getAt(i); } json.writeValue("r", r, Object[].class, Object.class); } else json.writeValue("c", "default"); json.writeObjectEnd(); }