I am using the Jackson JSON Lib in Java to process JSON. If you don’t know how JSON works in Ruby, you will like this project. Anyway. If you have dynamic JSON stream where the property names are not always the same, than you need the “@JsonAnySetter” Annotation. With that you can map dynamic Properties to a map.
private Map<String, Object> all = new HashMap<String, Object>(); @JsonAnySetter public void set(String name, Object value) { all.put(name, value); } public Map<String, Object> getAll() { return all; } public void setAll(Map<String, Object> all) { this.all = all; }
That worked out for me, for a String – String pair.
A related blog entry for creating “dyna-beans” is here: http://www.cowtowncoder.com/blog/archives/2011/07/entry_458.html