Parse JSON to cofigure android application

Luifhzegmgs

New Member
In my android app, I have to use JSON from server to make specific adjustment in the app.I'm trying to achive is to read this json and store all the values into local variables to perform actions inside the app.JSON From server:\[code\][ { "sett": " ", "glHdr": { "sm": [ ], "scleHPad": false, "st": "sbsm" }, "colrBG": [ 23, 105, 184, 100 ], "colrTB": [ 0, 0, 0, 0 ], "colrTR": [ 255, 255, 255, 100 ], "glFtr": { "icoSz": "icoSzN", "sm": [ ], "scleHPad": false, "gvNR": 3, "gvHIT": false, "gvNC": 3, "st": "igsm" }, "statBr": true }, { "sm": [ { "tbico": "b43-jeep.png", "t": "Welcome!", "w": "http://google.com/start", "st": "w", "wTBL": "wTBLN" }, { "t": "Content screen title", "f": "Eltec%20Spec%20sheet%20Gim%20RD30W.pdf", "st": "f" }, { "tbico": "109-chicken.png", "t": "Sub menu", "sm": [ { "t": "Screen 1", "st": "f" }, { "t": "Screen 2", "w": "Http://google.com", "st": "w", "wTBL": "wTBLT" } ], "st": "sm" }, { "st": "f" } ], "st": "tbm" }]\[/code\]To parse This I have created Parse JSON class, and trying to come up with method to read and store value of this json in my app.Function to do this:\[code\]public void doScanAppConfigJson(){private static final String = TAG_TITLE;private static final String = TAG_WEB_ADDRESS;private static final String = TAG_SCREEN_TYPE;private static final String = TAG_FILENAME; JSONArray appConfig = null; // Function for looping json object via ParseJson class. //Creating JSON Parser instance JSONParser jParser = new JSONParser(); //Getting json strings from url JSONObject jsonObject = jParser.getJSONFromUrl(url); try{ //Getting array of settings appConfig = jsonObject.getJSONArray(ConfigConstants.TABLE_VIEW_SUB_MENU_CONFIG); //loop throw all the objects under -sm[] for (int i = 0; i < appConfig.length(); i++){ JSONObject sm = appConfig.getJSONObject(i); //Now store each of this json in local constant var. String tabTitle = sm.getString(TAG_TITLE); String webAddress = sm.getString(TAG_WEB_ADDRESS); String screenType = sm.getString(TAG_SCREEN_TYPE); String fileName = sm.getString(TAG_FILENAME); } }catch (JSONException e){ e.printStackTrace(); } }\[/code\]And Im getting errors: \[code\]settingsjava.lang.NullPointException\[/code\] on this but i have define vars, Please some one tell me how do i parse above JSON. Am i on a right track to achieve ans. of my question?
 
Back
Top