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