当前位置: 首页>>代码示例>>Java>>正文


Java JSONArray.optJSONObject方法代码示例

本文整理汇总了Java中org.json.JSONArray.optJSONObject方法的典型用法代码示例。如果您正苦于以下问题:Java JSONArray.optJSONObject方法的具体用法?Java JSONArray.optJSONObject怎么用?Java JSONArray.optJSONObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.json.JSONArray的用法示例。


在下文中一共展示了JSONArray.optJSONObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: load

import org.json.JSONArray; //导入方法依赖的package包/类
private static boolean load(Context context) {
    JSONArray jsonArray = loadArray(context);
    if (jsonArray == null) {
        return false;
    }
    for (int i = 0; i < jsonArray.length(); i++) {
        JSONObject jo = jsonArray.optJSONObject(i);
        if (jo == null) {
            continue;
        }
        String pn = jo.optString("name");
        if (TextUtils.isEmpty(pn)) {
            continue;
        }

        PluginDesc pi = new PluginDesc(pn);
        pi.mDisplay = jo.optString("display");
        pi.mDesc = jo.optString("desc");
        pi.mLarge = jo.optBoolean("large");
        sMap.put(pn, pi);
    }
    return true;
}
 
开发者ID:wangyupeng1-iri,项目名称:springreplugin,代码行数:24,代码来源:PluginDesc.java

示例2: onHandleParsePeriods

import org.json.JSONArray; //导入方法依赖的package包/类
public boolean onHandleParsePeriods(JSONObject videoListJson, VideoListBean videoListBean) throws Exception {
    Iterator keyIter = videoListJson.keys();
    videoListBean.periodHashMap = new LinkedHashMap();
    while (keyIter.hasNext()) {
        String key = (String) keyIter.next();
        JSONArray array = videoListJson.optJSONArray(key);
        if (!(array == null || TextUtils.isEmpty(key) || TextUtils.equals(key, "varietyShow") || TextUtils.equals(key, "previewList"))) {
            VideoListBean arrayVideoBean;
            if (array.length() > 0) {
                arrayVideoBean = new VideoListBean();
            } else {
                arrayVideoBean = null;
            }
            for (int i = 0; i < array.length(); i++) {
                JSONObject json = array.optJSONObject(i);
                if (!isNull(json)) {
                    arrayVideoBean.add(VideoBean.parse(json));
                }
            }
            videoListBean.periodHashMap.put(key, arrayVideoBean);
        }
    }
    return true;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:25,代码来源:DownloadPagePeriodsParser.java

示例3: getUnder

import org.json.JSONArray; //导入方法依赖的package包/类
public JSONObject getUnder(final String id) throws RepositoryException {
	final JSONObject page = get(id);

	if (null == page) {
		return null;
	}

	final Query query = new Query()
			.setFilter(
					new PropertyFilter(Page.PAGE_ORDER, FilterOperator.GREATER_THAN, page.optInt(Page.PAGE_ORDER)))
			.addSort(Page.PAGE_ORDER, SortDirection.ASCENDING).setCurrentPageNum(1).setPageSize(1).setPageCount(1);

	final JSONObject result = get(query);
	final JSONArray array = result.optJSONArray(Keys.RESULTS);

	if (1 != array.length()) {
		return null;
	}

	return array.optJSONObject(0);
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:22,代码来源:PageDao.java

示例4: getErrors

import org.json.JSONArray; //导入方法依赖的package包/类
private List<String> getErrors(JSONObject jsonObject) throws JSONException {
    List<String> errors = list();
    JSONArray jsonArray = jsonObject.getJSONArray("errors");
    if (jsonArray == null || jsonArray.length() == 0) {
        return errors;
    }
    for (int i=0; i < jsonArray.length(); i++){
        String msg = null;

        JSONObject msgObj = jsonArray.optJSONObject(i);
        if (msgObj != null) {
            msg = msgObj.getString("message");
        } else {
            msg = jsonArray.get(i).toString();
        }

        errors.add(msg);
    }

    return errors;
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:22,代码来源:ParticleCloudException.java

示例5: parsePrecomps

import org.json.JSONArray; //导入方法依赖的package包/类
private static void parsePrecomps(
    @Nullable JSONArray assetsJson, LottieComposition composition) {
  if (assetsJson == null) {
    return;
  }
  int length = assetsJson.length();
  for (int i = 0; i < length; i++) {
    JSONObject assetJson = assetsJson.optJSONObject(i);
    JSONArray layersJson = assetJson.optJSONArray("layers");
    if (layersJson == null) {
      continue;
    }
    List<Layer> layers = new ArrayList<>(layersJson.length());
    LongSparseArray<Layer> layerMap = new LongSparseArray<>();
    for (int j = 0; j < layersJson.length(); j++) {
      Layer layer = Layer.Factory.newInstance(layersJson.optJSONObject(j), composition);
      layerMap.put(layer.getId(), layer);
      layers.add(layer);
    }
    String id = assetJson.optString("id");
    composition.precomps.put(id, layers);
  }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:24,代码来源:LottieComposition.java

示例6: getUpper

import org.json.JSONArray; //导入方法依赖的package包/类
public JSONObject getUpper(final String id) throws RepositoryException {
	final JSONObject category = get(id);

	if (null == category) {
		return null;
	}

	final Query query = new Query();

	query.setFilter(new PropertyFilter(Category.CATEGORY_ORDER, FilterOperator.LESS_THAN,
			category.optInt(Category.CATEGORY_ORDER))).addSort(Category.CATEGORY_ORDER, SortDirection.DESCENDING);
	query.setCurrentPageNum(1);
	query.setPageSize(1);

	final JSONObject result = get(query);
	final JSONArray array = result.optJSONArray(Keys.RESULTS);

	if (1 != array.length()) {
		return null;
	}

	return array.optJSONObject(0);
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:24,代码来源:CategoryDao.java

示例7: getUnder

import org.json.JSONArray; //导入方法依赖的package包/类
public JSONObject getUnder(final String id) throws RepositoryException {
	final JSONObject category = get(id);

	if (null == category) {
		return null;
	}

	final Query query = new Query();

	query.setFilter(new PropertyFilter(Category.CATEGORY_ORDER, FilterOperator.GREATER_THAN,
			category.optInt(Category.CATEGORY_ORDER))).addSort(Category.CATEGORY_ORDER, SortDirection.ASCENDING);
	query.setCurrentPageNum(1);
	query.setPageSize(1);

	final JSONObject result = get(query);
	final JSONArray array = result.optJSONArray(Keys.RESULTS);

	if (1 != array.length()) {
		return null;
	}

	return array.optJSONObject(0);
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:24,代码来源:CategoryDao.java

示例8: getUnder

import org.json.JSONArray; //导入方法依赖的package包/类
public JSONObject getUnder(final String id) throws RepositoryException {
	final JSONObject link = get(id);

	if (null == link) {
		return null;
	}

	final Query query = new Query();

	query.setFilter(new PropertyFilter(Link.LINK_ORDER, FilterOperator.GREATER_THAN, link.optInt(Link.LINK_ORDER)))
			.addSort(Link.LINK_ORDER, SortDirection.ASCENDING);
	query.setCurrentPageNum(1);
	query.setPageSize(1);

	final JSONObject result = get(query);
	final JSONArray array = result.optJSONArray(Keys.RESULTS);

	if (1 != array.length()) {
		return null;
	}

	return array.optJSONObject(0);
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:24,代码来源:LinkDao.java

示例9: parse

import org.json.JSONArray; //导入方法依赖的package包/类
private TenorGifResponse parse(@NonNull String s) {
    List<Gif> result = Collections.emptyList();
    String next = "";
    try {
        JSONObject object = new JSONObject(s);
        if (!JSONObject.NULL.equals(object)) {
            if (object.has("results")) {
                result = new ArrayList<>();
                JSONArray array = object.optJSONArray("results");
                for (int i = 0; i < array.length(); i++) {
                    JSONObject item = array.optJSONObject(i);
                    Gif gif = parseItem(item);
                    result.add(gif);
                }
            }
            if (object.has("next")) {
                next = object.optString("next");
            }
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }

    return new TenorGifResponse(result, next);
}
 
开发者ID:auv1107,项目名称:TextEmoji,代码行数:26,代码来源:TenorGifRemoteDataSource.java

示例10: surNameToUserID

import org.json.JSONArray; //导入方法依赖的package包/类
private void surNameToUserID() {
    if(userlist != null) {
        JSONArray jsa = userlist.optJSONArray("members");
        for (int i = 0; i < jsa.length(); i++) {
            JSONObject user = jsa.optJSONObject(i);
            String id = user.optString("id");
            if(jhUserIDs.contains(id)) {
                String name = user.optString("real_name").split(" ")[0];
                if (name != null) {
                    nameToUserID.put(name, id);
                }
            }
        }
    }
}
 
开发者ID:Jugendhackt,项目名称:SocialPaka,代码行数:16,代码来源:OcrCaptureActivity.java

示例11: getErrorCode

import org.json.JSONArray; //导入方法依赖的package包/类
public static int getErrorCode(JSONObject object) {
    JSONArray array = object.optJSONArray("errors");
    if (array == null || array.length() <= 0) {
        return 0;
    }
    JSONObject apiError = array.optJSONObject(0);
    if (apiError != null) {
        return apiError.optInt("code");
    }
    return 0;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:12,代码来源:ApiError.java

示例12: AnimatablePathValue

import org.json.JSONArray; //导入方法依赖的package包/类
AnimatablePathValue(Object json, LottieComposition composition) {
  if (hasKeyframes(json)) {
    JSONArray jsonArray = (JSONArray) json;
    int length = jsonArray.length();
    for (int i = 0; i < length; i++) {
      JSONObject jsonKeyframe = jsonArray.optJSONObject(i);
      PathKeyframe keyframe = PathKeyframe.Factory.newInstance(jsonKeyframe, composition,
          ValueFactory.INSTANCE);
      keyframes.add(keyframe);
    }
    Keyframe.setEndFrames(keyframes);
  } else {
    initialPoint = JsonUtils.pointFromJsonArray((JSONArray) json, composition.getDpScale());
  }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:16,代码来源:AnimatablePathValue.java

示例13: getByOrder

import org.json.JSONArray; //导入方法依赖的package包/类
public JSONObject getByOrder(final int order) throws RepositoryException {
	final Query query = new Query().setFilter(new PropertyFilter(Page.PAGE_ORDER, FilterOperator.EQUAL, order))
			.setPageCount(1);
	final JSONObject result = get(query);
	final JSONArray array = result.optJSONArray(Keys.RESULTS);

	if (0 == array.length()) {
		return null;
	}

	return array.optJSONObject(0);
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:13,代码来源:PageDao.java

示例14: getByPermalink

import org.json.JSONArray; //导入方法依赖的package包/类
public JSONObject getByPermalink(final String permalink) throws RepositoryException {
	final Query query = new Query()
			.setFilter(new PropertyFilter(Page.PAGE_PERMALINK, FilterOperator.EQUAL, permalink)).setPageCount(1);
	final JSONObject result = get(query);
	final JSONArray array = result.optJSONArray(Keys.RESULTS);

	if (0 == array.length()) {
		return null;
	}

	return array.optJSONObject(0);
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:13,代码来源:PageDao.java

示例15: parseJSONDefinition

import org.json.JSONArray; //导入方法依赖的package包/类
private static Map<Integer, Set<Integer>> parseJSONDefinition(JSONObject definition) {
    JSONArray itemsArray = definition.optJSONArray("items");
    if (itemsArray.length() == 0) {
        return null;
    }

    Map<Integer, Set<Integer>> items = new HashMap<>();
    for (int i = 0; i < itemsArray.length(); i++) {
        JSONObject item = itemsArray.optJSONObject(i);
        if (item == null) {
            continue;
        }
        int code = item.optInt("code");
        if (code == 0) {
            continue;
        }
        Set<Integer> subcodes = null;
        JSONArray subcodesArray = item.optJSONArray("subcodes");
        if (subcodesArray != null && subcodesArray.length() > 0) {
            subcodes = new HashSet<>();
            for (int j = 0; j < subcodesArray.length(); j++) {
                int subCode = subcodesArray.optInt(j);
                if (subCode != 0) {
                    subcodes.add(subCode);
                }
            }
        }
        items.put(code, subcodes);
    }
    return items;
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:32,代码来源:FacebookRequestErrorClassification.java


注:本文中的org.json.JSONArray.optJSONObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。