JSONObject getJSONArray - 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 getJSONArray method.

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:getJSONArray, getString, has
        long blackout = 0;
        Long sessionTimeout = null;
 
        if (!"".equals(policyJsonString)) {
            try { 
                JSONObject policyJSON = new JSONObject(policyJsonString);
                 
                if (policyJSON.has(BLACKLIST_KEY)) {
                    try { 
                        JSONArray blacklistJSON = policyJSON.getJSONArray(BLACKLIST_KEY);
 
                        for (int i = 0; i < blacklistJSON.length(); i++) {
                            blacklist.add(blacklistJSON.getString(i));
                        } 
                    } catch (JSONException e) {
                        QuantcastLog.w(TAG, "Failed to parse blacklist from JSON.", e);
                    } 
                } 
 
                if (policyJSON.has(SALT_KEY)) {

7
CodeRank
This code example shows how to use the following methods:get, getJSONArray, toString
	 */ 
	private boolean isJsonValid(JSONObject jsonObject) {
		 
		JSONArray zonesArray;
		try { 
			zonesArray = jsonObject.getJSONArray("zones");
			 
			if (jsonObject.get("x") == null ||  jsonObject.get("y") == null ||
				zonesArray.length() == 0 || !hasRealCoordinates(jsonObject) ){
					 
					log.debug("Json object isn't valid, no valid location , JSON =  "+jsonObject.toString());	
					return false; 
			} 
		 
		} catch (JSONException e) {
			log.error("JsonException ; Msg: "+e.getMessage() +" ; cause: " +e.getCause());
			return false; 
		} 
		 
		return true; 
7
CodeRank
This code example shows how to use the following methods:getJSONArray, has
			mUpdating = true;
		} 
 
		@Override 
		public void onSuccess(int statusCode, JSONObject response) {
			super.onSuccess(statusCode, response);
			if (statusCode == 200 && response.has("list")) {
				try { 
					if (mCurrentPage < 3) {
						new AddToDBThread(response.getJSONArray("list"), true)
								.start();
					} 
					mVideoAdapter.addVideosFromJsonArray(response
							.getJSONArray("list"));
					mVideoAdapter.notifyDataSetChanged();
				} catch (JSONException e) {
					e.printStackTrace();
				} 
			} 
		} 
7
CodeRank
This code example shows how to use the following methods:getJSONArray, getString, has
			return false; 
		} 
 
		try 
		{ 
			JSONObject jDesc = new JSONObject(desc);
 
			// String time = jDesc.getString(KEY_TIME); 
			// if(time.equalsIgnoreCase(VAL_RANDOM)) { 
			// mIsRandomized = true; 
			// } 
			// else { 
			// if(!mTrigTime.loadString(time)) { 
			// return false; 
			// } 
			// } 
 
			if (jDesc.has(KEY_START))
			{ 
 

6
CodeRank
This code example shows how to use the following methods:getJSONArray
     * @param data Objecto do tipo json que contem toda informação dos operadores 
     * @throws JSONException Em caso de erro é lançado uma excepção 
     */ 
    public void LoadOperators(JSONObject data) throws JSONException{
            //Selection Loader 
            JSONArray selector = data.getJSONArray("selection");
            if(selector.getString(0).equals("tournament")){
                System.out.println("selector:tournament -"+selector.getInt(1)+","+selector.getInt(2));
                operators.add( new operators.selections.Tournament(selector.getInt(1), selector.getInt(2)));
            } 
            if(selector.getString(0).equals("sus")){
                System.out.println("selector:sus - "+selector.getInt(1));
                operators.add( new operators.selections.SUS(selector.getInt(1)));
            }        
            if(selector.getString(0).equals("roulette")){
                System.out.println("selector:roulette - "+selector.getInt(1));
                operators.add( new operators.selections.Roulette(selector.getInt(1)));
            }  
             
            //Recombination Loader 

6
CodeRank
This code example shows how to use the following methods:getJSONArray
		} 
 
	} 
 
	private void showData(String json) throws JSONException {
		JSONObject o = new JSONObject(json);
		JSONArray data = o.getJSONArray("results");
 
		ListAdapter adapter = new JSONArrayAdapter(this,
				data,													// JSONArray data							
				android.R.layout.simple_list_item_2, 					// a layout resource to display a row
				new String[] {"from_user", "text"},						// field names from JSONObjects
				new int[] {android.R.id.text1, android.R.id.text2},		// corresponding View ids to map field names to 
				"id"													// id field from JSONObjects (optional) 
		); 
 
		getListView().setAdapter(adapter);
		getListView().setOnItemClickListener(this);
	} 
 
6
CodeRank
This code example shows how to use the following methods:getJSONArray, getString, has
     */ 
    public Presence(JSONObject json) throws Exception {
        super(json, Presence.action);
 
        try { 
            this.from = json.getString("from");
 
            String rawStatus = json.getString("status");
            if (rawStatus.equalsIgnoreCase("online"))
                this.status = Status.Online;
            else if (rawStatus.equalsIgnoreCase("offline"))
                this.status = Status.Offline;
            else 
                throw new Exception("Unsupported status");
 
            if (json.has("keys")) {
                JSONArray keys = json.getJSONArray("keys");
                this.keys = new ArrayList<Certificate>(keys.length());
 
                if (keys != null) {

6
CodeRank
This code example shows how to use the following methods:getJSONArray, getJSONObject, getString
	 * @param idscrapbook l'id du scrapbook 
	 * @param json le json d�crivant le scrapbbok 
	 */ 
	public static void decodeJSON (SQLiteDatabase myDb, long idscrapbook, String json){
		try { 
			JSONObject jsonObj = new JSONObject(json);
 
			String name = jsonObj.getString("name");
			String editor = jsonObj.getString("editor");
			String shareDate = jsonObj.getString("shareDate");
			JSONObject background = jsonObj.getJSONObject("background");
			String typeBackground = background.getString("type");
			String valeurBackground = background.getString("content");
 
			// Update BDD : NOM & BACKGROUND 
			ContentValues cv = new ContentValues();
			cv.put("name", name);
			cv.put("editor", editor);
			cv.put("shareDate", shareDate);
			cv.put("typeBackground", typeBackground);

6
CodeRank

Related JSONObject getJSONArray Questions & Answers:

Other JSONObject getJSONArray Examples

25:						if (jsonObj != null) {
26:							JSONArray categories = jsonObj
27:									.getJSONArray("categories");						
28:	
29:							for (int i = 0; i < categories.length(); i++) {

Read More

139:								JSONArray productObj = json
140:										.getJSONArray(TAG_PRODUCT); // JSON Array
141:	
142:								// get first product object from JSON Array
143:								JSONObject product = productObj.getJSONObject(0);

Read More

136:						// Getting Array of Products
137:						products = json.getJSONArray(TAG_PRODUCTS);
138:	
139:						// looping through All Products
140:						for (int i = 0; i < products.length(); i++) {

Read More

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