當前位置: 首頁>>代碼示例>>Java>>正文


Java JSONObject.getJSONArray方法代碼示例

本文整理匯總了Java中org.json.JSONObject.getJSONArray方法的典型用法代碼示例。如果您正苦於以下問題:Java JSONObject.getJSONArray方法的具體用法?Java JSONObject.getJSONArray怎麽用?Java JSONObject.getJSONArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.json.JSONObject的用法示例。


在下文中一共展示了JSONObject.getJSONArray方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: a

import org.json.JSONObject; //導入方法依賴的package包/類
static h a(JSONObject jSONObject) throws JSONException {
    if (jSONObject == null) {
        return null;
    }
    h hVar = new h();
    JSONObject jSONObject2 = jSONObject.getJSONObject("task_info");
    hVar.a = jSONObject2.getString("task_id");
    hVar.b = jSONObject2.getString("task_desc");
    JSONArray jSONArray = jSONObject2.getJSONArray("step_info");
    int length = jSONArray.length();
    if (length > 0) {
        hVar.c = new g[length];
    }
    for (int i = 0; i < length; i++) {
        jSONObject2 = jSONArray.getJSONObject(i);
        hVar.c[i] = new g(jSONObject2.getInt("step_no"), jSONObject2.getString("step_desc"), jSONObject2.getString("step_gift"), jSONObject2.getLong("end_time"), jSONObject2.getInt("status"));
    }
    return hVar;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:20,代碼來源:TaskGuide.java

示例2: getArrayString

import org.json.JSONObject; //導入方法依賴的package包/類
public static String[] getArrayString(JSONObject docObj, String name) {
	String[] list = null;
	if (docObj.has(name)) {
		JSONArray json;
		try {
			json = docObj.getJSONArray(name);
			int lenFeatures = json.length();
			list = new String[lenFeatures];
			for (int j = 0; j < lenFeatures; j++) {
				String f = json.getString(j);
				list[j] = f;
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}

	}
	return list;

}
 
開發者ID:NewCasino,項目名稱:browser,代碼行數:21,代碼來源:JSONUtil.java

示例3: getQuestionItems

import org.json.JSONObject; //導入方法依賴的package包/類
@Override
public Observable<List<QuestionItem>> getQuestionItems(String value) {
    List<QuestionItem> questionItems = new ArrayList<QuestionItem>();

    try {
        JSONObject jsonObject = new JSONObject(value);
        JSONArray array = jsonObject.getJSONArray("data");
        for (int i = 0; i < array.length(); i++) {
            JSONObject object = array.getJSONObject(i);
            JSONArray array1 = object.getJSONArray("list");
            List<Question> questions = new ArrayList<Question>();
            for (int j = 0; j < array1.length(); j++) {
                JSONObject object1 = array1.getJSONObject(j);
                Question question = new Question();
                question.setAnswer(object1.getString("desc"));
                question.setQuestion(object1.getString("title"));
                questions.add(question);
            }
            QuestionItem questionItem = new QuestionItem();
            questionItem.setName(object.getString("category"));
            questionItem.setQuestion(questions);
            questionItems.add(questionItem);
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }

    return Observable.just(questionItems);
}
 
開發者ID:Zyj163,項目名稱:yyox,代碼行數:30,代碼來源:OrderModel.java

示例4: build

import org.json.JSONObject; //導入方法依賴的package包/類
public void build(String data){

        try {
            // PHP에서 받아온 JSON 데이터를 JSON오브젝트로 변환
            JSONObject jObject = new JSONObject(data);
            // results라는 key는 JSON배열로 되어있다.
            JSONArray results = jObject.getJSONArray("result");
            String countTemp = (String)jObject.get("num_result");
            int count = Integer.parseInt(countTemp);

            for ( int i = 0; i < count; ++i ) {
                JSONObject temp = results.getJSONObject(i);
                convert(temp);

            }

        } catch (JSONException e) {
            e.printStackTrace();
        }

    }
 
開發者ID:pooi,項目名稱:Nearby,代碼行數:22,代碼來源:PatientPhoto.java

示例5: loadFromJSONObject

import org.json.JSONObject; //導入方法依賴的package包/類
@Override
protected void loadFromJSONObject(JSONObject obj, Database db) throws JSONException {
    JSONArray aggregateColumns = obj.getJSONArray(Members.AGGREGATE_COLUMNS.name());
    for (int ii = 0; ii < aggregateColumns.length(); ii++) {
        JSONObject aggregateColumn = aggregateColumns.getJSONObject(ii);
        m_aggregateTypes.add(ExpressionType.valueOf(aggregateColumn.getString(Members.AGGREGATE_TYPE.name())));
        m_aggregateColumnNames.add(aggregateColumn.getString(Members.AGGREGATE_NAME.name()));
        m_aggregateColumnGuids.add(aggregateColumn.getInt(Members.AGGREGATE_GUID.name()));
        m_aggregateOutputColumns.add(aggregateColumn.getInt(Members.AGGREGATE_OUTPUT_COLUMN.name()));
    }
    
    try {
        JSONArray groupbyColumnGuids = obj.getJSONArray(Members.GROUPBY_COLUMNS.name());
        for (int ii = 0; ii < groupbyColumnGuids.length(); ii++) {
            JSONObject jsonObject = groupbyColumnGuids.getJSONObject(ii);
            PlanColumn column = PlanColumn.fromJSONObject(jsonObject, db);
            m_groupByColumnGuids.add(column.guid());
        }
    } catch (JSONException e) {
        //okay not to be there.
    }
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:23,代碼來源:AggregatePlanNode.java

示例6: parser

import org.json.JSONObject; //導入方法依賴的package包/類
public RedPacketBean parser(JSONObject data) throws Exception {
    parsePollingController(data);
    RedPacketBean bean = new RedPacketBean();
    if (has(data, "blockContent")) {
        JSONArray jsonArray = data.getJSONArray("blockContent");
        if (!(jsonArray == null || jsonArray.length() == 0)) {
            RedPacketSdkManager.getInstance().setRedPacketList(jsonArray);
        }
        bean = parserRedPacketList(jsonArray);
        bean.type = RedPacketBean.TYPE_REDPACKET;
    }
    this.mPollingResult.hasRedPacket = RedPacketSdkManager.getInstance().hasRedPacket(bean);
    if (this.mCallback != null) {
        this.mCallback.onReceivePollingResult(this.mPollingResult);
        this.mCallback = null;
    }
    LogInfo.log("RedPacketParser", "parser + Network is ok,parse polling result is finish");
    return bean;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:20,代碼來源:RedPacketParser.java

示例7: parseItems

import org.json.JSONObject; //導入方法依賴的package包/類
private void parseItems(List<GalleryItem> items, JSONObject jsonBody)
        throws IOException, JSONException {

    JSONObject photosJsonObject = jsonBody.getJSONObject("photos");
    JSONArray photoJsonArray = photosJsonObject.getJSONArray("photo");

    for (int i = 0; i < photoJsonArray.length(); i++) {
        JSONObject photoJsonObject = photoJsonArray.getJSONObject(i);

        GalleryItem item = new GalleryItem();
        item.setId(photoJsonObject.getString("id"));
        item.setCaption(photoJsonObject.getString("title"));
        
        if (!photoJsonObject.has("url_s")) {
            continue;
        }
        
        item.setUrl(photoJsonObject.getString("url_s"));
        items.add(item);
    }
}
 
開發者ID:rsippl,項目名稱:AndroidProgramming3e,代碼行數:22,代碼來源:FlickrFetchr.java

示例8: loadFromJSONObject

import org.json.JSONObject; //導入方法依賴的package包/類
protected void loadFromJSONObject(JSONObject object, Database db) throws JSONException {
    super.loadFromJSONObject(object, db);
    JSONArray executeList = object.getJSONArray(Members.EXECUTE_LIST.name());
    for (int ii = 0; ii < executeList.length(); ii++) {
        Integer id = executeList.getInt(ii);
        m_list.add(m_idToNodeMap.get(id));
    }
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:9,代碼來源:PlanNodeList.java

示例9: QoSServerResultDesc

import org.json.JSONObject; //導入方法依賴的package包/類
/**
 * 
 * @param json
 * @throws JSONException
 */
public QoSServerResultDesc(JSONObject json) throws JSONException {
	this.desc = json.getString(JSON_KEY_DESCRIPTION);
	this.testType = QoSTestResultEnum.valueOf(json.getString(JSON_KEY_TESTTYPE));
	this.status = DetailType.valueOf(json.getString(JSON_KEY_STATUS).toUpperCase(Locale.US));
	JSONArray uidArray = json.getJSONArray(JSON_KEY_UID_LIST);
	for (int i = 0; i < uidArray.length(); i++) {
		uidSet.add(uidArray.getLong(i));
	}
}
 
開發者ID:rtr-nettest,項目名稱:open-rmbt,代碼行數:15,代碼來源:QoSServerResultDesc.java

示例10: parseUserConnections

import org.json.JSONObject; //導入方法依賴的package包/類
public static ArrayList<UserConnection> parseUserConnections(JSONObject object) {
    ArrayList<UserConnection> connections = null;
    try {
        JSONArray connObj = object.getJSONArray("user_connections");
        return (ArrayList) new Gson().fromJson(connObj.toString(), new
                TypeToken<ArrayList<UserConnection>>() {
        }.getType());
    } catch (JSONException e) {
        e.printStackTrace();
        return connections;
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:13,代碼來源:UserConnection.java

示例11: parsStreams

import org.json.JSONObject; //導入方法依賴的package包/類
ArrayList<Lydstream> parsStreams(JSONObject jsonobj) throws JSONException {
  ArrayList<Lydstream> lydData = new ArrayList<>();

  String subtitles = null;
  JSONArray jsonArraySubtitles = jsonobj.optJSONArray("SubtitlesList"); //Forventer den kan være tom
  if (jsonArraySubtitles != null) {
    //Antagelse: Vil altid kun være 1 subtitle, på dansk. Dog tjekkes det i et for-loop og leder efter dansk, hvis nu antagelsen er forkert.
    for (int i = 0; i < jsonArraySubtitles.length(); i++) {
      JSONObject jsonSubtitles = jsonArraySubtitles.getJSONObject(i);
      if (jsonSubtitles.getString("Language").equals("Danish")) {
        subtitles = jsonSubtitles.getString("Uri");
      } else Log.d("Findes andre subtitles på sprog: " + jsonSubtitles.getString("Language"));
    }
  }

  JSONArray jsonArrayStreams = jsonobj.getJSONArray("Links");
  for (int k = 0; k < jsonArrayStreams.length(); k++) {
    JSONObject jsonStream = jsonArrayStreams.getJSONObject(k);
    String type = jsonStream.getString("Target");
    if ("HDS".equals(type)) continue; // HDS (HTTP Dynamic Streaming fra Adobe) kan ikke afspilles på Android

    //if (App.fejlsøgning) Log.d("streamjson=" + jsonStream);
    Lydstream l = new Lydstream();
    l.url = jsonStream.getString("Uri");

    if ("Download".equals(type)) {
      l.type = Lydstream.StreamType.HTTP_Download;
      l.bitrate_ubrugt = jsonStream.getInt("Bitrate");
    } else {
      l.type = Lydstream.StreamType.HLS_fra_Akamai;
    }
    l.kvalitet = Lydstream.StreamKvalitet.Variabel;
    l.subtitlesUrl = subtitles;
    lydData.add(l);
  }
  return lydData;
}
 
開發者ID:nordfalk,項目名稱:EsperantoRadio,代碼行數:38,代碼來源:MuOnlineBackend.java

示例12: handleWeatherResponse

import org.json.JSONObject; //導入方法依賴的package包/類
/**
 *
 * 處理得到的 weather 數據,轉化為 weather 對象
 */
public static Weather handleWeatherResponse(String response){
    try{
        JSONObject jsonObject = new JSONObject(response);
        JSONArray jsonArray = jsonObject.getJSONArray("HeWeather5");
        String weatherContent = jsonArray.getJSONObject(0).toString();
        return new Gson().fromJson(weatherContent, Weather.class);
    }catch (Exception e){
        e.printStackTrace();
    }
    return null;
}
 
開發者ID:LynnYuki,項目名稱:CoolCloud-Weather,代碼行數:16,代碼來源:Utility.java

示例13: downloadComment

import org.json.JSONObject; //導入方法依賴的package包/類
private void downloadComment() {
    StringRequest strReq = new StringRequest(Request.Method.POST,
            AppConfig.URL_COMMENTS, new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            try {
                JSONObject jObj = new JSONObject(response);
                JSONArray feedArray = jObj.getJSONArray("comments");
                adapter.CommentsList.clear();
                for (int i = 0; i < feedArray.length(); i++) {
                    final JSONObject feedComment = (JSONObject) feedArray.get(i);
                    //add product to list products
                    Comments comment = new Comments(feedComment.getString("userid"), feedComment.getString("username"), feedComment.getString("time"),
                                                    feedComment.getString("contentcomment"), feedComment.getString("userpic"), feedComment.getString("rate"));
                    adapter.CommentsList.add(comment);
                }
                // Load detail fragment if in tablet mode
                commentView.setAdapter(adapter);
                adapter.notifyDataSetChanged();

            } catch (Exception ex) {
                // JSON parsing error
                ex.printStackTrace();
            }
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            error.printStackTrace();
        }
    }) {
        @Override
        protected Map<String, String> getParams() {
            // Posting parameters to login url
            Map<String, String> params = new HashMap<>();
            params.put("userid", userid + "");
            return params;
        }
    };
    strReq.setTag(this.getClass().getName());
    VolleySingleton.getInstance(getActivity()).requestQueue.add(strReq);
}
 
開發者ID:sega4revenge,項目名稱:Sega,代碼行數:43,代碼來源:CommentFragment.java

示例14: onPostExecute

import org.json.JSONObject; //導入方法依賴的package包/類
protected void onPostExecute(String response) {
            if (response == null) {
                response = "THERE WAS AN ERROR";
            }
            progressBar.setVisibility(View.GONE);
            Log.i("INFO", response);
            //responseView.setText(response);
            try {
                JSONObject object = (JSONObject) new JSONTokener(response).nextValue();
                JSONArray obj1 = object.getJSONArray("result");
                JSONObject obj = obj1.getJSONObject(0);
                //   String email1 = obj.getString("country");
                // System.out.println(email1);
                int rating1 = 0, maxrating1 = 0;
                String country1 = null, city1 = null, contribution1 = null, firstname = null, lastname = null;
                if (obj.has("rating"))
                    rating1 = obj.getInt("rating");
                if (rating1 != 0)
                    rating.setText(rating1 + "");
                else rating.setText("Not Found ");
                if (obj.has("country"))
                    country1 = obj.getString("country");
                else country1 = "Not Found ";
                country.setText(country1);
                if (obj.has("city"))
                    city1 = obj.getString("city");
                else city1 = "Not Found ";
                city.setText(city1);
                if (obj.has("maxRating"))
                    maxrating1 = obj.getInt("maxRating");
                if (maxrating1 != 0)
                    maxrating.setText(maxrating1 + "");
                else maxrating.setText("Not Found");
                if (obj.has("contribution"))
                    contribution1 = obj.getString("contribution");
                else contribution1 = "Not Found";
                contribution.setText(contribution1);
                if (obj.has("firstName"))
                    firstname = obj.getString("firstName");
                else firstname = "Not Found";
                if (obj.has("lastName"))
                    lastname = obj.getString("lastName");
                else lastname = "";
                username.setText(firstname + " " + lastname);
                submission.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        String url = "http://codeforces.com/submissions/" + handle.getText().toString();
                    }
                });
            } catch (JSONException e) {
                e.printStackTrace();
            }


//            try {
//                JSONObject object = (JSONObject) new JSONTokener(response).nextValue();
//                String requestID = object.getString("requestId");
//                int likelihood = object.getInt("likelihood");
//                JSONArray photos = object.getJSONArray("photos");
//                .
//                .
//                .
//                .
//            } catch (JSONException e) {
//                e.printStackTrace();
//            }
        }
 
開發者ID:mkfeuhrer,項目名稱:CodeMania,代碼行數:69,代碼來源:Userdata.java

示例15: getArtwork

import org.json.JSONObject; //導入方法依賴的package包/類
public void getArtwork(Track track) {
    final String currentArtist = "" + track.getArtist();

    if (currentArtist.equals(""))
        return;

    if (MediaUtils.getArtworkQuick(context, track, 300, 300) != null)
        return;

    if (activeTasks.size() > 2)
        return;

    if (activeTasks.containsKey(currentArtist))
        return;

    activeTasks.put(currentArtist, this);

    AQuery aq = new AQuery(context);
    String url = String.format("http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&api_key=683548928700d0cdc664691b862a8d21&artist=%s&format=json", Uri.encode(currentArtist));
    AjaxCallback<JSONObject> cb = new AjaxCallback<JSONObject>();
    cb.url(url).type(JSONObject.class).fileCache(true).expire(3600 * 60 * 1000);
    aq.sync(cb);
    JSONObject result = cb.getResult();

    if (result != null) {
        JSONObject jsonObject = null;
        String albumArtImageLink = null;
        try {
            if (!result.has("artist"))
                return;

            jsonObject = result.getJSONObject("artist");
            JSONArray image = jsonObject.getJSONArray("image");
            for (int i=0;i<image.length();i++) {
                jsonObject = image.getJSONObject(i);
                if (jsonObject.getString("size").equals("extralarge")) {
                    albumArtImageLink = Uri.decode(jsonObject.getString("#text"));
                }
            }
            if (!(albumArtImageLink != null && albumArtImageLink.equals(""))) {
                String path = MediaUtils.getArtistPath(track);
                if (path != null) {
                    File file = new File(path);

                    AjaxCallback<File> cbFile = new AjaxCallback<File>();
                    cbFile.url(albumArtImageLink).type(File.class).targetFile(file);
                    aq.sync(cbFile);

                    AjaxStatus status = cbFile.getStatus();
                    if (status.getCode() == 200) {
                        if (listener != null)
                            listener.onNewArtwork();
                    } else {
                        file.delete();
                    }
                }
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
    activeTasks.remove(currentArtist);
}
 
開發者ID:dmllr,項目名稱:IdealMedia,代碼行數:65,代碼來源:TaskGetArtwork.java


注:本文中的org.json.JSONObject.getJSONArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。