2011-05-25

Deserialize JSON with Jackson into Polymorphic Types - A Complete Example

Jackson API Versions Note

The following code examples were written using Jackson 1.7.x or 1.8.x. They probably work as-is with Jackson 1.9.x, but Jackson 2.0 introduced API changes significant enough that this code does not compile with it. On initial review, it appears that package names changed, and at least one method signature changed or was moved or was renamed or no longer exists. In the near future, I may post updated code examples that use Jackson 2.x.

tl;dnr

Skip to the fourth, fifth, and sixth examples.

Why This Post Exists

While recently answering a question on StackOverflow.com about deserialization of JSON into polymorhpic types in Java, I couldn't find a simple and complete example using Jackson. At the time of this writing, the official documentation on the subject describes aspects of how to do this, but it doesn't have a full example. Searching other resources also didn't turn up any complete examples.
Link To This ArticleQR Code Link To This Articlehttp://goo.gl/nVKBZ

Following are deserialization examples with Jackson that build up to a complete example of populating a polymorphic data structure in Java. The first three examples do not involve Polymorphism. Polymorphism is introduced in the fourth example.

2011-05-20

Fixing GeekYouUp's Battery Widget

tl;dnr

GeekYouUp's Battery Widget for Android can be altered to reduce App Widget display update occurrences by as much as 40-65% (depending on device power use rate), without altering application functionality or otherwise hindering its ability to display the current battery charge level. Battery Widget's constantly running service, necessary for real-time monitoring of battery charge level changes, appears to use negligible resources and does not noticeably prematurely drain battery power.
Link To This ArticleQR Code Link To This Articlehttp://goo.gl/mscyj

Following are links to the code of the fixed version of Battery Widget, logs of the svn differences showing what was changed from the original code, and a fully-built Android APK, ready to be installed on any Android device. This APK was built with a different package name, a different application name, and a different digital signature than the Battery Widget application by GeekYouUp. It can be installed in parallel with the original -- it does not replace the original Battery Widget application during installation.

For Those With Interest In The Details...