@SuppressWarnings("unchecked") @Test public void testAnonymous() throws Exception { ObjectMapper mapper = new ObjectMapper(); String orgJson = IOUtils.toString(getClass().getResourceAsStream("open_doc.json"), "UTF-8"); FlexDoc d = mapper.readValue(orgJson, FlexDoc.class); assertEquals("doc_id", d.getId()); assertEquals("unknown", d.getAnonymous().get("mysteryStringField")); assertEquals(12345, d.getAnonymous().get("mysteryIntegerField")); Map<String, Object> mysteryObject = (Map<String, Object>) d.getAnonymous().get("mysteryObjectField"); assertEquals("foo", mysteryObject.get("nestedField1")); assertEquals("bar", mysteryObject.get("nestedField2")); List<String> mysteryList = (List<String>) d.getAnonymous().get("mysteryArrayField"); assertEquals(3, mysteryList.size()); assertEquals("a1", mysteryList.get(0)); String newJson = mapper.writeValueAsString(d); assertTrue(JSONComparator.areEqual(newJson, orgJson)); }
private Map<String, Object> anonymous() { if (anonymous == null) { anonymous = new HashMap<String, Object>(); } return anonymous; }
OpenCouchDbDocument extends CouchDbDocument { private Map<String, Object> anonymous() { if (anonymous == null) { anonymous = new HashMap<String, Object>(); } return anonymous; } }
OpenCouchDbDocument extends CouchDbDocument { private Map<String, Object> anonymous() { if (anonymous == null) { anonymous = new HashMap<String, Object>(); } return anonymous; }  }
OpenCouchDbDocument extends CouchDbDocument { private Map<String, Object> anonymous() { if (anonymous == null) { anonymous = new HashMap<String, Object>(); } return anonymous; }  @JsonAnyGetter Map<String, Object> getAnonymous(); @JsonAnySetter void setAnonymous(String key, Object value); }
OpenCouchDbDocument extends CouchDbDocument { private Map<String, Object> anonymous() { if (anonymous == null) { anonymous = new HashMap<String, Object>(); } return anonymous; }  @JsonAnyGetter Map<String, Object> getAnonymous(); @JsonAnySetter void setAnonymous(String key, Object value);  }