Friday, February 24, 2012

Sifter-Java

SifterReader actually started as a Java wrapper for the SifterAPI. Fork it on Github. This was my first Java foray, and I wanted to practice before making a full-on Android app. One of the things I quickly realized is that JSON is an ideal container for data objects. <There were several SO Q-A's on this topic that I'll add refs for later.> Sure you could make a custom object, like I did here originally for projects, and what you'll find in the C#, Ruby and Python (which I contributed to) wrappers. And Java also has some nice convenient map containers like HashMap. But all of those methods add an extra step, although it's true that some of the other JSON parsers like google-gson and json-simple can cast a JSON object directly to a HashMap. In the end I left the Sifter objects as JSONObjects, because I found org.json to have all of the functionality I needed. And it made passing them in intent bundles from activity to activity or writing them to files super easy since I just cast them back to string.

No comments:

Post a Comment

Fork me on GitHub