Allow more flexibility with JSON marshalling of non-entity beans

This commit is contained in:
Rob Bygrave
2013-08-02 12:16:00 +12:00
parent bf8574833a
commit 9c7f62e8b1
2 changed files with 5 additions and 5 deletions
@@ -71,25 +71,24 @@ public class WriteJsonContext implements JsonWriter {
public void toJson(String name, Collection<?> c) {
internalAppendKeyBegin(name);
beginAssocMany(name);
Iterator<?> it = c.iterator();
if (!it.hasNext()){
buffer.append("[]");
endAssocMany();
return;
}
Object o = it.next();
BeanDescriptor<?> d = getDecriptor(o.getClass());
appendArrayBegin();
d.jsonWrite(this, o);
while (it.hasNext()) {
appendComma();
Object t = it.next();
d.jsonWrite(this, t);
}
appendArrayEnd();
endAssocMany();
}
private <T> BeanDescriptor<T> getDecriptor(Class<T> cls) {