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


Java JSONArray.getJSONObject方法代码示例

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


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

示例1: validateMosaic

import net.sf.json.JSONArray; //导入方法依赖的package包/类
/**
 * validate the mosaic and quantity
 * @param address
 * @param mosaicName
 * @param mosaicQuantity
 * @param mosaicFeeInformation
 * @return
 */
private static String validateMosaic(String address, String mosaicName, String mosaicQuantity, MosaicFeeInformation mosaicFeeInformation) {
	String queryResult = HttpClientUtils.get(Constants.URL_ACCOUNT_MOSAIC_OWNED + "?address=" + address);
	JSONObject json = JSONObject.fromObject(queryResult);
	JSONArray array = json.getJSONArray("data");
	for(int i=0;i<array.size();i++){
		JSONObject item = array.getJSONObject(i);
		// get mosaic id
		JSONObject mosaicId = item.getJSONObject("mosaicId");
		String namespaceId = mosaicId.getString("namespaceId");
		String name = mosaicId.getString("name");
		// get mosaic quantity
		long quantity = item.getLong("quantity");
		if(mosaicName.equals(namespaceId+":"+name)){
			Double mQuantity = Double.valueOf(mosaicQuantity).doubleValue() * Math.pow(10, mosaicFeeInformation.getDivisibility());
			if(mQuantity.longValue()>quantity){
				return "insufficient mosaic quantity";
			} else {
				return null;
			}
		}
	}
	return "there is no mosaic ["+mosaicName+"] in the account";
}
 
开发者ID:NEMChina,项目名称:nem-apps,代码行数:32,代码来源:ImplInitMultisigTransaction.java

示例2: handleJson

import net.sf.json.JSONArray; //导入方法依赖的package包/类
public void handleJson(String jsonContent) throws Exception {
	JSONArray array = JSONArray.fromObject(jsonContent);
	JSONObject object = null;
	int l = array.size();
	for (int i = 0; i < l; i++) {
		object = array.getJSONObject(i);
		JSONObject obj1 = (JSONObject) object.get("data");
		JSONObject obj2 = (JSONObject) obj1.get("archives");
		for (int j = 0; j < 20; j++) {
			JSONObject obj3 = (JSONObject) obj2.get(String.valueOf(j));
			Bilibili video = new Bilibili();
			video.setAid(Integer.parseInt(obj3.get("aid").toString()));
			video.setTid(Integer.parseInt(obj3.get("tid").toString()));
			video.setTname((obj3.get("tname")).toString());
			video.setTitle((obj3.get("title")).toString());
			video.setAuthor((obj3.get("author")).toString());
			JSONObject obj4 = (JSONObject) obj3.get("stat");
			video.setCoin(Integer.parseInt(obj4.get("coin").toString()));
			video.setFavorite(Integer.parseInt(obj4.get("favorite").toString()));
			JDBC.insertBilibiliData(conn, video);
		}
	}
}
 
开发者ID:bighuang624,项目名称:BiliInfoCrawler,代码行数:24,代码来源:Test.java

示例3: getDTOArray

import net.sf.json.JSONArray; //导入方法依赖的package包/类
/**
 * 从一个JSON数组得到一个java对象数组,形如: [{"id" : idValue, "name" : nameValue}, {"id" :
 * idValue, "name" : nameValue}, ...]
 * 
 * @param object
 * @param clazz
 * @return
 */
public static Object[] getDTOArray(String jsonString, Class<?> clazz) {
	setDataFormat2JAVA();
	JSONArray array = JSONArray.fromObject(jsonString);
	Object[] obj = new Object[array.size()];
	for (int i = 0; i < array.size(); i++) {
		JSONObject jsonObject = array.getJSONObject(i);
		obj[i] = JSONObject.toBean(jsonObject, clazz);
	}
	return obj;
}
 
开发者ID:jiangzongyao,项目名称:kettle_support_kettle8.0,代码行数:19,代码来源:JSONUtil.java

示例4: getVideoNumber

import net.sf.json.JSONArray; //导入方法依赖的package包/类
public int getVideoNumber(String jsonContent) throws Exception {
	JSONArray array = JSONArray.fromObject(jsonContent);
	JSONObject object = null;
	int l = array.size();
	int videoNumber = 0;
	for (int i = 0; i < l; i++) {
		object = array.getJSONObject(i);
		JSONObject obj1 = (JSONObject) object.get("data");
		JSONObject obj2 = (JSONObject) obj1.get("page");
		videoNumber = Integer.parseInt(obj2.get("count").toString());
	}
	return videoNumber;
}
 
开发者ID:bighuang624,项目名称:BiliInfoCrawler,代码行数:14,代码来源:Test.java

示例5: getFriendList

import net.sf.json.JSONArray; //导入方法依赖的package包/类
/**
 * 获取好友列表相当于组里的所有人
 * 
 * @param userGroupTopId
 *            组id
 * @param token
 *            身份
 * @return
 */
public static List<UserData> getFriendList(String userGroupTopId, String token) {
	JSONObject js = new JSONObject();
	js.put("hOpCode", "13");
	js.put("userGroupTopId", userGroupTopId);
	Map<String, String> header = new HashMap<>();
	header.put("hOpCode", "13");
	header.put("token", token);
	byte[] returnByte = HttpUtil.send(js.toString(), CommonConfigChat.IDENTITY_URL, header, HttpUtil.POST);
	if (returnByte != null) {
		String str = null;
		try {
			str = new String(returnByte, "UTF-8");
		} catch (UnsupportedEncodingException e) {
			WSManager.log.error("返回字符串解析异常", e);
		}
		JSONObject returnjs = JSONObject.fromObject(str);
		// 如果返回的是错误类型,说明用户中心拦截器没通过
		if (returnjs.getString("hOpCode").equals("0")) {
			return null;
		}
		JSONArray jsArray = returnjs.getJSONArray("user");
		List<UserData> list = new ArrayList<>();
		for (int i = 0; i < jsArray.size(); i++) {
			JSONObject user = jsArray.getJSONObject(i);
			UserData userData = new UserData(user);
			list.add(userData);
		}
		return list;
	}
	return null;
}
 
开发者ID:dianbaer,项目名称:anychat,代码行数:41,代码来源:IdentityAction.java

示例6: findMosaicFeeInformationByNIS

import net.sf.json.JSONArray; //导入方法依赖的package包/类
/**
 * Find mosaic fee information by NIS.
 *
 * @param mosaicId the mosaic id
 * @return the mosaic fee information
 */
public static MosaicFeeInformation findMosaicFeeInformationByNIS(MosaicId mosaicId){
	String host = "alice2.nem.ninja";
	String port = "7890";
	NemNetworkResponse queryResult = NetworkUtils.get("http://"+host+":"+port+NemAppsLibGlobals.URL_NAMESPACE_MOSAIC_DEFINITION_PAGE + "?namespace=" + mosaicId.getNamespaceId().toString());
	
	
	JSONObject json = JSONObject.fromObject(queryResult.getResponse());
	if(json==null || !json.containsKey("data") || json.getJSONArray("data").size()==0){
		return null;
	}
	JSONArray array = json.getJSONArray("data");
	for(int i=0;i<array.size();i++){
		JSONObject item = array.getJSONObject(i);
		JSONObject mosaic = item.getJSONObject("mosaic");
		JSONObject id = mosaic.getJSONObject("id");
		if(mosaicId.getName().equals(id.getString("name"))){
			JSONArray properties = mosaic.getJSONArray("properties");
			String initialSupply = "";
			String divisibility = "";
			for(int j=0;j<properties.size();j++){
				JSONObject property = properties.getJSONObject(j);
				if("initialSupply".equals(property.getString("name"))){
					initialSupply = property.getString("value");
				} else if("divisibility".equals(property.getString("name"))){
					divisibility = property.getString("value");
				}
			}
			if(!"".equals(initialSupply) && !"".equals(divisibility)){
				return new MosaicFeeInformation(Supply.fromValue(Long.valueOf(initialSupply)), Integer.valueOf(divisibility));
			}
		}
	}
	return null;
}
 
开发者ID:NEMPH,项目名称:nem-apps-lib,代码行数:41,代码来源:NISQuery.java

示例7: findMosaicFeeInformationByNIS

import net.sf.json.JSONArray; //导入方法依赖的package包/类
public static MosaicFeeInformation findMosaicFeeInformationByNIS(MosaicId mosaicId){
	String queryResult = HttpClientUtils.get(Constants.URL_NAMESPACE_MOSAIC_DEFINITION_PAGE + "?namespace=" + mosaicId.getNamespaceId().toString());
	JSONObject json = JSONObject.fromObject(queryResult);
	if(json==null || !json.containsKey("data") || json.getJSONArray("data").size()==0){
		return null;
	}
	JSONArray array = json.getJSONArray("data");
	for(int i=0;i<array.size();i++){
		JSONObject item = array.getJSONObject(i);
		JSONObject mosaic = item.getJSONObject("mosaic");
		JSONObject id = mosaic.getJSONObject("id");
		if(mosaicId.getName().equals(id.getString("name"))){
			JSONArray properties = mosaic.getJSONArray("properties");
			String initialSupply = "";
			String divisibility = "";
			for(int j=0;j<properties.size();j++){
				JSONObject property = properties.getJSONObject(j);
				if("initialSupply".equals(property.getString("name"))){
					initialSupply = property.getString("value");
				} else if("divisibility".equals(property.getString("name"))){
					divisibility = property.getString("value");
				}
			}
			if(!"".equals(initialSupply) && !"".equals(divisibility)){
				return new MosaicFeeInformation(Supply.fromValue(Long.valueOf(initialSupply)), Integer.valueOf(divisibility));
			}
		}
	}
	return null;
}
 
开发者ID:NEMChina,项目名称:nem-apps,代码行数:31,代码来源:NISQuery.java

示例8: initGlobalDataConfig

import net.sf.json.JSONArray; //导入方法依赖的package包/类
protected void initGlobalDataConfig(JSON globalDataConfigs) {

        JSONArray array = getGlobalConfigsArray(globalDataConfigs);

        for (int i = 0; i < array.size(); i++) {
            JSONObject jsonobject = array.getJSONObject(i);
            addGlobalConfigDataForSonarInstance(jsonobject);
        }
    }
 
开发者ID:jenkinsci,项目名称:sonar-quality-gates-plugin,代码行数:10,代码来源:GlobalConfigurationService.java


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