Posts

Showing posts from May, 2012

Gson's missing get element function - Part I

The Gson missing recursive get function. One of the issues with the current get function that is available is that it only search’s top-level entry key for the value that is passed in. Example JsonObject result; // json object for the preview below If a result.get(“username”) is done the following set will return null because as I have said above the inbuilt get function only search top level element you wish to find. The following values exists in the top-level [“result”, “error”, “id”] the inner elements will not be searched which is part of the flaw / weakness of using the in-built method. A solution to this problem is show below: {     "result" : {         "total_items" : 1 ,         "total_pages" : 1 ,         "items_per_page" : 25 ,         "current_page" : 1 ,         "items" : [{                 "username" : "test" ,                 "api