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


Java JSONObject.optJSONArray方法代码示例

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


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

示例1: parseResolveScanResponse

import org.json.JSONObject; //导入方法依赖的package包/类
private static Collection<PwsResult> parseResolveScanResponse(JSONObject result) {
    // Get the metadata array.
    Collection<PwsResult> pwsResults = new ArrayList<>();
    JSONArray metadata = result.optJSONArray("results");
    if (metadata == null) {
        // There are no valid results.
        return pwsResults;
    }

    // Loop through the metadata for each url.
    for (int i = 0; i < metadata.length(); i++) {
        try {
            pwsResults.add(PwsResult.jsonDeserialize(metadata.getJSONObject(i)));
        } catch (JSONException e) {
            Log.e(TAG, "PWS returned invalid data", e);
            continue;
        }
    }
    return pwsResults;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:21,代码来源:PwsClientImpl.java

示例2: AttestationResult

import org.json.JSONObject; //导入方法依赖的package包/类
public AttestationResult(String decodedPayload) throws JSONException {
    JSONObject jo = new JSONObject(decodedPayload);
    nonce = jo.optString("nonce", "");
    apkDigestSha256 = jo.optString("apkDigestSha256", "");
    apkPackageName = jo.optString("apkPackageName", "");
    basicIntegrity = jo.optBoolean("basicIntegrity", false);
    ctsProfileMatch = jo.optBoolean("ctsProfileMatch", false);
    timestampMs = jo.optLong("timestampMs", 0);
    extension = jo.optString("extension", "");
    JSONArray ja = jo.optJSONArray("apkCertificateDigestSha256");
    if (ja != null) {
        String[] certDigests = new String[ja.length()];
        for (int i = 0; i < ja.length(); i++) {
            certDigests[i] = ja.getString(i);
        }
        apkCertificateDigestSha256 = certDigests;
    }
}
 
开发者ID:Catherine22,项目名称:SecuritySample,代码行数:19,代码来源:AttestationResult.java

示例3: parsePrecomps

import org.json.JSONObject; //导入方法依赖的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

示例4: parse

import org.json.JSONObject; //导入方法依赖的package包/类
private List<EmojiCategory> parse(String data) {
    List<EmojiCategory> result = Collections.emptyList();
    try {
        JSONObject object = new JSONObject(data);
        JSONArray array = object.optJSONArray("data");
        if (array != null && array.length() > 0) {
            result = new ArrayList<>();
            for (int i = 0; i < array.length(); i++) {
                EmojiCategory category = EmojiCategory.fromJson(array.optJSONObject(i));
                if (!category.isEmpty()) {
                    result.add(category);
                }
            }
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return result;
}
 
开发者ID:auv1107,项目名称:TextEmoji,代码行数:20,代码来源:EmojiLocalDataSource.java

示例5: getShopList

import org.json.JSONObject; //导入方法依赖的package包/类
public static List<ShopInfo> getShopList(String result) {
    List<ShopInfo> list = new ArrayList<>();
    ShopInfo info;
    try {
        JSONObject obj = new JSONObject(result);
        JSONArray infoArr = obj.optJSONArray("info");
        int len  = infoArr.length();
        for (int i = 0; i < len; i++) {
            JSONObject temp = infoArr.getJSONObject(i);
            info = new ShopInfo();
            info.setId(temp.optString("id"));
            info.setName(temp.optString("name"));
            info.setImgUrl(temp.optString("icon"));
            list.add(info);
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return list;
}
 
开发者ID:RealMoMo,项目名称:72GGames_Demo,代码行数:21,代码来源:ParseUtil.java

示例6: parseList

import org.json.JSONObject; //导入方法依赖的package包/类
public static LinkedList<BooheeAdvertisementBean> parseList(JSONObject object) {
    JSONArray array = object.optJSONArray("advertisements");
    if (array == null) {
        return null;
    }
    return (LinkedList) new Gson().fromJson(array.toString(), new
            TypeToken<LinkedList<BooheeAdvertisementBean>>() {
    }.getType());
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:10,代码来源:BooheeAdvertisementBean.java

示例7: getLocations

import org.json.JSONObject; //导入方法依赖的package包/类
/**
 * Extract created user locations from the bulk response.
 * @param response
 * @return
 * @throws JSONException
 */
public ArrayList<String> getLocations (String response) throws JSONException {

    ArrayList<String> UserLocations = new ArrayList<>();

    JSONObject jsonObject = new JSONObject(response);
    JSONArray jsonarray = jsonObject.optJSONArray("Operations");
    for (int i = 0; i < jsonarray.length(); i++) {
        JSONObject innerJsonobject = jsonarray.getJSONObject(i);
        String location = innerJsonobject.getString("location");
        UserLocations.add(location);
    }

    return UserLocations;
}
 
开发者ID:wso2-incubator,项目名称:scim2-compliance-test-suite,代码行数:21,代码来源:BulkTest.java

示例8: getMostCommentArticles

import org.json.JSONObject; //导入方法依赖的package包/类
public List<JSONObject> getMostCommentArticles(final int num) throws RepositoryException {
	final Query query = new Query().addSort(Article.ARTICLE_COMMENT_COUNT, SortDirection.DESCENDING)
			.addSort(Article.ARTICLE_UPDATE_DATE, SortDirection.DESCENDING)
			.setFilter(new PropertyFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true))
			.setCurrentPageNum(1).setPageSize(num).setPageCount(1);

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

	return CollectionUtils.jsonArrayToList(array);
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:12,代码来源:ArticleDao.java

示例9: parseSurveyOptions

import org.json.JSONObject; //导入方法依赖的package包/类
public static SurveyOptionsModel parseSurveyOptions(String response){
	
	SurveyOptionsModel optionsMode = new SurveyOptionsModel();
	if (TextUtils.isEmpty(response)) {
		return optionsMode;
	}
	
	try {
		JSONObject json = new JSONObject(response);
		JSONObject result = json.getJSONObject("result");
		if (result.has("title")) {
			optionsMode.setTitle(result.getString("title"));
		}
		if (result.has("desc")) {
			optionsMode.setDesc(result.getString("desc"));
		}
		if (result.has("options")) {
			
			List<OptionsModel> options = new ArrayList<OptionsModel>();
			JSONArray optionsArray = result.optJSONArray("options");
			if (optionsArray != null && optionsArray.length() > 0) {
				for (int i = 0; i < optionsArray.length(); i++) {
					JSONObject data = optionsArray.optJSONObject(i);
					OptionsModel optionItem = new OptionsModel();
					optionItem.setId(data.optString("id"));
					optionItem.setText(data.getString("text"));
					options.add(optionItem);
				}
			}
			optionsMode.setOptions(options);
		}
	} catch (JSONException e) {
		e.printStackTrace();
	}
	return optionsMode;
	
}
 
开发者ID:lennyup,项目名称:react-native-udesk,代码行数:38,代码来源:JsonUtils.java

示例10: parseDialogConfigurations

import org.json.JSONObject; //导入方法依赖的package包/类
private static Map<String, Map<String, DialogFeatureConfig>> parseDialogConfigurations(
        JSONObject dialogConfigResponse) {
    HashMap<String, Map<String, DialogFeatureConfig>> dialogConfigMap = new HashMap<String, Map<String, DialogFeatureConfig>>();

    if (dialogConfigResponse != null) {
        JSONArray dialogConfigData = dialogConfigResponse.optJSONArray("data");
        if (dialogConfigData != null) {
            for (int i = 0; i < dialogConfigData.length(); i++) {
                DialogFeatureConfig dialogConfig = DialogFeatureConfig.parseDialogConfig(
                        dialogConfigData.optJSONObject(i));
                if (dialogConfig == null) {
                    continue;
                }

                String dialogName = dialogConfig.getDialogName();
                Map<String, DialogFeatureConfig> featureMap = dialogConfigMap.get(dialogName);
                if (featureMap == null) {
                    featureMap = new HashMap<String, DialogFeatureConfig>();
                    dialogConfigMap.put(dialogName, featureMap);
                }
                featureMap.put(dialogConfig.getFeatureName(), dialogConfig);
            }
        }
    }

    return dialogConfigMap;
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:28,代码来源:Utility.java

示例11: parseJSONDefinition

import org.json.JSONObject; //导入方法依赖的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

示例12: getRelations

import org.json.JSONObject; //导入方法依赖的package包/类
private List<RelationType> getRelations(final JSONObject jsonObject) {
    JSONArray relation = jsonObject.optJSONArray("relation");
    if (relation == null) {
        return Collections.emptyList();
    }

    List<RelationType> relationTypes = new ArrayList<>();
    for (int i = 0; i < relation.length(); i++) {
        RelationType relationType = RelationType.getRelationType(relation.optString(i));
        if (relationType != null) {
            relationTypes.add(relationType);
        }
    }
    return relationTypes;
}
 
开发者ID:openid,项目名称:OpenYOLO-Android,代码行数:16,代码来源:WebAssetStatementDeserializer.java

示例13: getByTitle

import org.json.JSONObject; //导入方法依赖的package包/类
public JSONObject getByTitle(final String categoryTitle) throws RepositoryException {
	final Query query = new Query()
			.setFilter(new PropertyFilter(Category.CATEGORY_TITLE, FilterOperator.EQUAL, categoryTitle))
			.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,代码行数:15,代码来源:CategoryDao.java

示例14: initSlider

import org.json.JSONObject; //导入方法依赖的package包/类
private void initSlider(JSONObject object) {
    JSONArray slidersArray = object.optJSONArray("sliders");
    if (slidersArray == null || slidersArray.length() <= 0) {
        this.sliders = null;
    } else {
        this.sliders = HomeSlider.parseSliders(slidersArray.toString());
    }
    initHeadAd();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:10,代码来源:NewPartnerFragment.java

示例15: Stats

import org.json.JSONObject; //导入方法依赖的package包/类
public Stats(JSONObject obj) throws JSONException {
    timezone = TimeZone.getTimeZone(obj.getString("3"));

    entries = new ArrayList<>();
    JSONArray entriesArray = obj.optJSONArray("1");
    if (entriesArray == null) return; // There are no entries, it's not an error!
    for (int i = 0; i < entriesArray.length(); i++)
        entries.add(new Entry(entriesArray.getJSONObject(i)));
}
 
开发者ID:devgianlu,项目名称:PlayConsoleAndroidAPI,代码行数:10,代码来源:Stats.java


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