JSONObject obj = new JSONObject();
for (String key : doc.keySet()) {
Object value = doc.get(key);
obj.put(key, value);
}
return obj.toJSONString();
}
private <T extends Document> T fromString(Collection<T> collection, String data) throws ParseException {
T doc = collection.newDocument(this);
Map<String, Object> obj = (Map<String, Object>) new JSONParser().parse(data);