Skip to main content


Showing posts from April, 2011

JSON to Java Bean conversion for Android

I have written a small add-on for inbuilt JSON Lib of Android ( org.json.* ). Android's in-build JSON library is very permeative and provides just the basic functionalities. There is no Tokenize functionality which can automatically convert a JSON string into its relevant Java Bean class. Though there are few alternate open source libraries like jackson-json , gson  etc. But the inbuilt JSON library of Android is pretty simple to use and with this add-on you'll be able to get the missing flavor of auto-bean conversion. How to use it ? Please download the and include in your Android project source code. It provides an important method parse() which can convert a JSON string into Java Bean class. It uses Java re-factoring, so Bean class field name and JSON property name should exactly match. Let's look into how to parse a simple JSON structure- String jsonString = "{name: 'Jon Smith', id: 1234, " +     "address: {cityName

Overriding In JavaScript

Here I'll explain the usage of a powerful keyword/programming structure of JavaScript, " prototype ". It is one of the member variable of Function object and Function object is kind of Supper class for any function that you write in JavaScript. Every function in Javascript is of type Function object. " prototype " provides really a powerful and simple way of extending JavaScript Object and Override their existing functions. Prototype provides additional look up chain for variable and method definition search . So, lets take an example, say there is a JavaScript object Person having First and Last name and we want to override  the default toString() method of prototype property. toString() displays string representation of any object.                function Person (fname, lname){                        this.fname = fname;                        this.lname = lname;                }                Person . prototype .toString = function(){