that_person

Android: Parsing JSON Docs (via http://goo.gl/xFTTgn)

Aug 6th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.40 KB | None | 0 0
  1. public PushMessage(String jsonMessage) throws PreyException{
  2.     try {
  3.         JSONObject jsonObj = new JSONObject(jsonMessage);
  4.         JSONObject data = jsonObj.getJSONObject("data");
  5.         this.event = jsonObj.getString("event");
  6.         this.type = data.getString("type");
  7.         this.body = data.getString("body");
  8.     } catch (JSONException e) {
  9.         throw new PreyException("Couldn't parse pushed json message");
  10.     }
  11.          
  12.          
  13. }
Add Comment
Please, Sign In to add comment