I am getting information from a MySql DB via PHP. The information is returned in the following JSON array:
06-15 15:20:17.400: E/JSON(9865): {"tag":"get_game_state","success":1,"error":0,"GameState":{"monster":"Troll","qty":"1","exp":"0"}}
The json is parsed and string is built using StringBuilder
. Now that I have the information returned I want to parse it for the individual strings/ints it contains to put them in a local sqlite db.
Here are the two lines in question
userFunctions.getServerGameState(email, monster, qty, exp); //this line gets the JSON array and the above information is returned
db.saveLocalGameSate(monster, qty, exp); //this line should take that information take String monster int exp and int qty and put them in the local db.
How should I convert that returned information into an individual string and ints so that they can be used in the next line of code? Any direction to some resources would be very helpful.
update
I have added the following lines inbetween the two above lines of code, output is a null pointer exception
try {
JSONArray arr = new JSONArray(GameState);
JSONObject jObj = arr.getJSONObject(0);
String virtumon = jObj.getString("monster");
Integer qty = jObj.getInt("qty");
Integer exp = jObj.getInt("exp");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}