Created
August 6, 2014 17:13
-
-
Save j-onathan/c406fb2d1874901681af to your computer and use it in GitHub Desktop.
Android Code Example: Parsing JSON Documents (from https://www.codota.com/android/scenarios/52fcbd28da0a75bbf7091889/parsing-json-documents?tag=dragonfly)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public PushMessage(String jsonMessage) throws PreyException{ | |
try { | |
JSONObject jsonObj = new JSONObject(jsonMessage); | |
JSONObject data = jsonObj.getJSONObject("data"); | |
this.event = jsonObj.getString("event"); | |
this.type = data.getString("type"); | |
this.body = data.getString("body"); | |
} catch (JSONException e) { | |
throw new PreyException("Couldn't parse pushed json message"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment