JSONObject getJSONObject - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for JSONObject getJSONObject method.

This code example shows how to use the following methods:getJSONObject, getString
	private String type;
	private String body;
	 
	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"); 
		} 
		 
		 
	} 
	 
	public String getEvent() {
		return event;
	} 
-10
CodeRank
This code example shows how to use the following methods:getJSONArray, getJSONObject, has, put
10
CodeRank
This code example shows how to use the following methods:getJSONArray, getJSONObject
import org.json.JSONWriter; 
 
import com.google.refine.Jsonizable; 
import com.google.refine.ProjectManager; 
import com.google.refine.ProjectMetadata; 
import com.google.refine.model.Project; 
import com.google.refine.util.JSONUtilities; 
 
 
public class ImportingJob implements Jsonizable { 
    final public long id;
    final public File dir; // Temporary directory where the data about this job is stored
     
    private JSONObject config;
     
    public Project project;
    public ProjectMetadata metadata;
     
    public long lastTouched;
    public boolean updating;

7
CodeRank
This code example shows how to use the following methods:getInt, getJSONObject, getString
                    System.err.println("Empty response during initialization.");
                } 
                return false; 
            } 
 
            JSONObject json = new JSONObject(new String(b));
 
            this.uuid = json.getString("uuid");
 
            JSONObject proto = json.getJSONObject("protocol");
 
            if (!isCompatible(proto)) {
                if (debug) {
                    System.err
                            .println("Driver not compatible with adapter protocol: "
                                    + proto);
                } 
                return false; 
            } 
 

7
CodeRank
This code example shows how to use the following methods:getJSONObject, getString
	private static final long serialVersionUID = -6166266603350967003L;
 
	public DirectMessageJSON() { 
	} 
	public DirectMessageJSON(JSONObject json) throws Exception {
		_createdAt = Time.getTwitterDate(json.getString("created_at"));
		_senderScreenName = json.getString("sender_screen_name");
		_sender = new UserJSON(json.getJSONObject("sender"));
		_text = Utils.unescape(json.getString("text"));
		_recipientScreenName = json.getString("recipient_screen_name");
		_id = json.getLong("id");
		_recipient = new UserJSON(json.getJSONObject("recipient"));
		_recipientId = json.getLong("recipient_id");
		_senderId = json.getLong("sender_id");
	} 
	public DirectMessageJSON(JSONObject json, boolean outgoing) throws Exception {
		_createdAt = Time.getTwitterDate(json.getString("created_at"));
		_senderScreenName = json.getString("sender_screen_name");
		_sender = new UserJSON(json.getJSONObject("sender"));
		_text = Utils.unescape(json.getString("text"));
7
CodeRank
This code example shows how to use the following methods:get, getJSONObject, keys
        assertEquals(0, resp.getContentLength());
 
        // Get the preferences 
 
        resp = sendRequest(new GetRequest(URL), 200);
        jsonResult = new JSONObject(resp.getContentAsString());
        assertNotNull(jsonResult);
        assertTrue(jsonResult.keys().hasNext());
 
        checkJSONObject(jsonResult);
        checkJSONObject(jsonResult.getJSONObject("comp1"));
 
        // Update some of the preferences 
 
        jsonObject.put("stringValue", "updated");
        jsonObject.put("comp2", getPreferenceObj());
 
        resp = sendRequest(new PostRequest(URL, jsonObject.toString(), "application/json"), 200);
        assertEquals(0, resp.getContentLength());
 

7
CodeRank
This code example shows how to use the following methods:getJSONObject, has, isNull
        public ArrayList<TrainDeparture> trains = new ArrayList<TrainDeparture>();
 
        public static Departures fromJson(JSONObject json) throws JSONException {
            Departures d = new Departures();
 
            if (!json.isNull("serves_types")) {
                JSONArray jsonServesTypes = json.getJSONArray("serves_types");
                for (int i = 0; i < jsonServesTypes.length(); i++) {
                    d.servesTypes.add(jsonServesTypes.getString(i));
                } 
            } 
 
            if (!json.isNull("metros")) {
                JSONObject jsonMetros = json.getJSONObject("metros");
                if (jsonMetros.has("group_of_lines")) {
                    d.metros.add(MetroDeparture.fromJson(jsonMetros));
                } 
            } 
 
            if (!json.isNull("buses")) {
                JSONArray jsonBuses = json.getJSONArray("buses");
7
CodeRank
This code example shows how to use the following methods:getJSONObject, getNames
    } 
 
    private JSONObject cloneJSON( JSONObject jsonObject )
        throws JSONException 
    { 
        String[] names = JSONObject.getNames( jsonObject );
        if( names == null )
        { 
            names = EMPTY_NAMES;
        } 
        return new JSONObject( jsonObject, names );
    } 
 
    @Override 
    public EntityReference associationValueOf( QualifiedName stateName )
    { 
        try 
        { 
            Object jsonValue = state.getJSONObject( JSON_KEY_ASSOCIATIONS ).opt( stateName.name() );
            if( jsonValue == null )

7
CodeRank
This code example shows how to use the following methods:getInt, getJSONObject
    this.width = width;
 
  } 
 
  public UIARect(JSONObject o) throws JSONException {
    JSONObject origin = o.getJSONObject("origin");
    x = origin.getInt("x");
    y = origin.getInt("y");
 
    JSONObject size = o.getJSONObject("size");
    height = size.getInt("height");
    width = size.getInt("width");
  } 
 
  public String toString() {
    return "origin(x=" + x + ",y=" + y + "),size(height=" + height + ",width=" + width + ")";
  } 
 
  public int getX() { 
    return x;
7
CodeRank
This code example shows how to use the following methods:getJSONObject, getString
	User sender;
	String id;
 
	public Comment(JSONObject obj, String accessToken)
			throws JSONException { 
		super(obj, accessToken);
		setCreatedTimestamp(obj.getString("created_time"));
		setText(obj.getString("text"));
		setId(obj.getString("id"));
		setSender((new User(obj.getJSONObject("from"), accessToken)));
	} 
 
	public String getCreatedTimestamp() {
		return createdTimestamp;
	} 
 
	protected void setCreatedTimestamp(String createdTimestamp) {
		this.createdTimestamp = createdTimestamp;
	} 
 
7
CodeRank

Related JSONObject getJSONObject Questions & Answers:

Other JSONObject getJSONObject Examples

62:					try {
63:						JSONObject jObj = new JSONObject(json)
64:								.getJSONObject("game_stat");
65:						now_playing = jObj.getString("now_playing");
66:						earned = jObj.getString("earned");

Read More

63:								// Store user details in SQLite Database
64:								DatabaseHandler db = new DatabaseHandler(getApplicationContext());
65:								JSONObject json_user = json.getJSONObject("user");
66:								
67:								// Clear all previous data in database

Read More

63:								// Store user details in SQLite Database
64:								DatabaseHandler db = new DatabaseHandler(getApplicationContext());
65:								JSONObject json_user = json.getJSONObject("user");
66:								
67:								// Clear all previous data in database

Read More

getJSONObject Method Overview
Returns the value mapped by name if it exists and is a JSONObject.
See Code Examples for other Android JSONObject Methods: