Skip to content

Instantly share code, notes, and snippets.

@JanPaulEttles
Created December 8, 2011 15:37
Show Gist options
  • Select an option

  • Save JanPaulEttles/1447332 to your computer and use it in GitHub Desktop.

Select an option

Save JanPaulEttles/1447332 to your computer and use it in GitHub Desktop.
consistentstructure #1
public class TestDBObjectFactory {
public static DBObject createJson() {
DBObject doc = new BasicDBObject();
doc.put("_id", "someGeneratedValue");
doc.put("nameOne", "valueOne");
doc.put("nameTwo", "valueTwo");
DBObject sub = new BasicDBObject();
sub.put("subNameOne", "subValueOne");
sub.put("subNameTwo", "subValueTwo");
doc.put("sub", sub);
ArrayList array = new ArrayList();
array.add(new BasicDBObject("arraySubNameOne", "arraySubValueOne"));
array.add(new BasicDBObject("arraySubNameTwo", "arraySubValueTwo"));
doc.put("array", array);
return doc;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment