Android JSONException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android JSONException class.

This code example shows how to use the following methods:getMessage
                Log.d("NotificationPlugin", "Notification: " + tag + ", " + title + ", " + body);
                int notificationFlag = getFlagValue(flag);
                showNotification(tag, title, body, notificationFlag);
            } catch (JSONException jsonEx) {
                Log.d("NotificationPlugin", "Got JSON Exception "
                        + jsonEx.getMessage());
                actionValid = false;
            } 
        } else if (CLEAR.equals(action)){
            try { 
                String tag = data.getString(0);
                Log.d("NotificationPlugin", "Notification cancel: " + tag);
                clearNotification(tag);
            } catch (JSONException jsonEx) {
                Log.d("NotificationPlugin", "Got JSON Exception " + jsonEx.getMessage());
                actionValid = false;
            } 
        } else { 
            actionValid = false;
            Log.d("NotificationPlugin", "Invalid action : "+action+" passed");
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:printStackTrace
    public void save(Writer writer) {
        JSONWriter jsonWriter = new JSONWriter(writer);
        try { 
            write(jsonWriter, new Properties());
        } catch (JSONException e) {
            e.printStackTrace();
        } 
    } 
     
    static public ColumnGroup load(String s) throws Exception {
        JSONObject obj = ParsingUtilities.evaluateJsonStringToObject(s);
         
        return new ColumnGroup( 
            obj.getInt("startColumnIndex"),
            obj.getInt("columnSpan"),
            obj.getInt("keyColumnIndex")
        ); 
    } 
     
    protected void internalInitialize() { 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:printStackTrace
    public void save(Writer writer) {
        JSONWriter jsonWriter = new JSONWriter(writer);
        try { 
            write(jsonWriter, new Properties());
        } catch (JSONException e) {
            e.printStackTrace();
        } 
    } 
     
    static public Column load(String s) throws Exception {
        JSONObject obj = ParsingUtilities.evaluateJsonStringToObject(s);
        Column column = new Column(obj.getInt("cellIndex"), obj.getString("originalName"));
         
        column._name = obj.getString("name");
        if (obj.has("reconConfig")) {
            column._reconConfig = ReconConfig.reconstruct(obj.getJSONObject("reconConfig"));
        } 
        if (obj.has("reconStats")) {
            column._reconStats = ReconStats.load(obj.getJSONObject("reconStats"));
        } 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMessage
                        Arrays.sort(r, 0, r.length);
                         
                        return r;
                    } catch (JSONException e) {
                        return new EvalError(ControlFunctionRegistry.getFunctionName(this) +
                                " fails to process a JSON array: " + e.getMessage());
                    } 
                } else if (v instanceof List<?>) {
                    List<? extends Comparable<Object>> a = (List<? extends Comparable<Object>>) v;
                    Collections.sort(a);
                     
                    return a;
                } 
            } 
        } 
        return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects an array");
    } 
 
    @Override 
    public void write(JSONWriter writer, Properties options)
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMessage
    try { 
      JSONObject c = new JSONObject();
      c.put("desiredCapabilities", session.getRequestedCapabilities());
      return c.toString();
    } catch (JSONException  e) {
      throw new NewSessionException("Error with the request " + e.getMessage(),e);
    } 
  } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:printStackTrace
    public void save(Writer writer, Properties options) {
        JSONWriter jsonWriter = new JSONWriter(writer);
        try { 
            write(jsonWriter, options);
        } catch (JSONException e) {
            e.printStackTrace();
        } 
    } 
     
    static public Cell loadStreaming(String s, Pool pool) throws Exception {
        JsonFactory jsonFactory = new JsonFactory(); 
        JsonParser jp = jsonFactory.createJsonParser(s);
         
        if (jp.nextToken() != JsonToken.START_OBJECT) {
            return null; 
        } 
         
        return loadStreaming(jp, pool);
    } 
     
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:e, getMessage
        JSONObject obj = new JSONObject();
        try { 
            obj.put("level", batteryIntent.getIntExtra(android.os.BatteryManager.EXTRA_LEVEL, 0));
            obj.put("isPlugged", batteryIntent.getIntExtra(android.os.BatteryManager.EXTRA_PLUGGED, -1) > 0 ? true : false);
        } catch (JSONException e) {
            Log.e(LOG_TAG, e.getMessage(), e);
        } 
        return obj;
    } 
 
    /** 
     * Updates the JavaScript side whenever the battery changes 
     * 
     * @param batteryIntent the current battery information 
     * @return 
     */ 
    private void updateBatteryInfo(Intent batteryIntent) {
        sendUpdate(this.getBatteryInfo(batteryIntent), true);
    } 
 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMessage
		} 
		catch (UnmarshallException e) {
			throw new UnmarshallException("key " + key + " " + e.getMessage(), e);
		} 
		catch (JSONException e) {
			throw new UnmarshallException("key " + key + " " + e.getMessage(), e);
		} 
		return m;
	} 
 
	public Object unmarshall(SerializerState state, Class clazz, Object o) throws UnmarshallException {
		JSONObject jso = (JSONObject) o;
		String java_class;
		try { 
			java_class = jso.getString("javaClass");
		} 
		catch (JSONException e) {
			throw new UnmarshallException("Could not read javaClass", e);
		} 
		if (java_class == null) {
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:printStackTrace
            mUrl = object.getString("url");
            if (object.has("embeddable_url")) {
                mExpandedUrl = object.getString("embeddable_url");
            } 
        } catch (JSONException e) {
            e.printStackTrace();
        } 
    } 
 
    @Override 
    public String toString() {
        JSONObject object = new JSONObject();
        try { 
            object.put("url", mUrl);
            object.put("thumbnail_url", mThumbnailUrl);
            object.put("embeddable_url", mExpandedUrl);
        } catch (JSONException e) {
            e.printStackTrace();
        } 
        return object.toString();
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMessage
    try { 
      res = getResponse(request);
      response.getWriter().print(res);
      response.getWriter().close();
    } catch (JSONException e) {
      throw new GridException(e.getMessage());
    } 
 
  } 
 
  private JSONObject getResponse(HttpServletRequest request) throws IOException, JSONException {
    JSONObject requestJSON = null;
    if (request.getInputStream() != null) {
      BufferedReader rd = new BufferedReader(new InputStreamReader(request.getInputStream()));
      StringBuilder s = new StringBuilder();
      String line;
      while ((line = rd.readLine()) != null) {
        s.append(line);
      } 
      rd.close();
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android JSONException Questions & Answers:

Other Android JSONException Examples

5:	    object.put("current", new Double(152.32));
6:	    object.put("nickname", "Hacker");
7:	  } catch (JSONException e) {
8:	    e.printStackTrace();
9:	  }

Read More

68:						Log.e("JSON", "> " + now_playing + earned);
69:	
70:					} catch (JSONException e) {
71:						// TODO Auto-generated catch block
72:						e.printStackTrace();

Read More

43:						}
44:	
45:					} catch (JSONException e) {
46:						e.printStackTrace();
47:					}

Read More

59:							// Phone node is JSON Object
60:							JSONObject phone = c.getJSONObject(TAG_PHONE);
61:							String mobile = phone.getString(TAG_PHONE_MOBILE);
62:							String home = phone.getString(TAG_PHONE_HOME);
63:							String office = phone.getString(TAG_PHONE_OFFICE);

Read More

See Code Examples for Android JSONException Methods: