Jackson JSON User Group

JSON in Java the Right Way -- Action, Jackson!

New feature: ability to "update" beans, not just recreate

One feature that has been requested occasionally has been ability to update properties of existing Objects. That is, given a Bean, bind whatever properties JSON object has and override existing values, but don't bother constructing a new instance. It hasn't been high priority thing to add, but today I realized that it would be rather easy to implement -- and, maybe most importantly, I found a use case of my own for this feature (basically for priority/overrides for config files).

So, I went ahead and implemented this (see 1.6 plans page for more details). Here's how you can use the feature:

Bean bean = new Bean();
// set properties, whatever, and:
new ObjectMapper().updatingReader(bean).readValue("{ \"name\" : \"Jackson\"}");
// 'bean' is also reported by readValue() call, as usual

(as you can see from above, annother related improvement is addition of ObjectReader abstraction -- to match ObjectWriter that 1.5 added -- it was added to prevent combinatorial explosion
with new configuration settings)



Views: 169

Tags: jackson, json

Comment

You need to be a member of Jackson JSON User Group to add comments!

Join Jackson JSON User Group

© 2012   Created by Tatu Saloranta.   Powered by .

Badges  |  Report an Issue  |  Terms of Service