JsonObject obj = new JsonObject();
JsonObject vals = new JsonObject();
for(Entry<PropertyKey, Object> entry : attributes.entrySet()) {
PropertyKey key = entry.getKey();
Object value = entry.getValue();
if (value == null) {
vals.add(key.jsonName(), null);
} else {
vals.add(key.jsonName(), new JsonPrimitive(value.toString()));
}
}
obj.add(getErrorToken(), vals);