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


Java JSONObject.getJSONObject方法代码示例

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


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

示例1: validateMosaic

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

import net.sf.json.JSONObject; //导入方法依赖的package包/类
public static UserData getUser(String token) {
	JSONObject js = new JSONObject();
	js.put("hOpCode", "11");
	Map<String, String> header = new HashMap<>();
	header.put("hOpCode", "11");
	header.put("token", token);
	byte[] returnByte = HttpUtil.send(js.toString(), CommonConfig.UCENTER_URL, header, HttpUtil.POST);
	if (returnByte != null) {
		String str = null;
		try {
			str = new String(returnByte, "UTF-8");
		} catch (UnsupportedEncodingException e) {
			HttpConfig.log.error("返回字符串解析异常", e);
		}
		JSONObject returnjs = JSONObject.fromObject(str);
		// 如果返回的是错误类型,说明用户中心拦截器没通过
		if (returnjs.getString("hOpCode").equals("0")) {
			return null;
		}
		UserData userData = new UserData(returnjs.getJSONObject("user"));
		return userData;
	}
	return null;
}
 
开发者ID:dianbaer,项目名称:epay,代码行数:25,代码来源:IdentityAction.java

示例3: getUser

import net.sf.json.JSONObject; //导入方法依赖的package包/类
/**
 * 获取用户信息
 * 
 * @param token
 *            身份
 * @return
 */
public static UserData getUser(String token) {
	JSONObject js = new JSONObject();
	js.put("hOpCode", "11");
	Map<String, String> header = new HashMap<>();
	header.put("hOpCode", "11");
	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;
		}
		UserData userData = new UserData(returnjs.getJSONObject("user"));
		return userData;
	}
	return null;
}
 
开发者ID:dianbaer,项目名称:anychat,代码行数:32,代码来源:IdentityAction.java

示例4: extractErrorMessage

import net.sf.json.JSONObject; //导入方法依赖的package包/类
@Override
protected String extractErrorMessage(String response) {
    if (response != null && !response.isEmpty()) {
        try {
            JSON jsonResponse = JSONSerializer.toJSON(response, new JsonConfig());
            if (jsonResponse instanceof JSONObject) {
                JSONObject object = (JSONObject) jsonResponse;
                JSONObject errorObj = object.getJSONObject("error");
                if (errorObj.containsKey("message")) {
                    return errorObj.getString("message");
                }
            }
        } catch (JSONException ex) {
            log.debug("Cannot parse JSON error response: " + response);
        }
    }
    return response;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:19,代码来源:BlazeMeterHttpUtils.java

示例5: onPreInitialize

import net.sf.json.JSONObject; //导入方法依赖的package包/类
@Override
public void onPreInitialize(AGContext context, JSONObject initArgs) {
    Log.d(TAG, "onPreInitialize(%s)", context.hashCode());
    ArbitraryGenProcessor processor = context.getProcessor("javaCodeEngine");
    if (processor instanceof JavaCodeAGEngine) {
        JavaCodeAGEngine engine = (JavaCodeAGEngine) processor;
        AGAnnotationWrapper annWrapper = new AGAnnotationWrapper();
        annWrapper.addAnnotationProcessor(new IPCInvokeTaskProcessor());
        engine.addTypeDefWrapper(annWrapper);

        JSONObject javaCodeEngine = initArgs.getJSONObject("javaCodeEngine");
        if (javaCodeEngine != null) {
            if (!javaCodeEngine.containsKey("ruleFile") && !javaCodeEngine.containsKey("rule")) {
                javaCodeEngine.put("rule", "${project.projectDir}/src/main/java/*.java");
            }
        }
    }
}
 
开发者ID:AlbieLiang,项目名称:IPCInvoker,代码行数:19,代码来源:IPCInvokerAGContextExtension.java

示例6: getSelfInfo

import net.sf.json.JSONObject; //导入方法依赖的package包/类
public final User getSelfInfo(){
	JSONObject data=JSONObject.fromObject(utils.get(URL.URL_GET_SELF_INFO,new HttpHeader[]{URL.URL_REFERER,credential.getCookie()}).getContent("UTF-8"));
	JSONObject info=data.getJSONObject("result");
	//获取生日
	JSONObject birthday=info.getJSONObject("birthday");
	//构造一个用户
	User user=new User(info.getLong("account"));
	//设置昵称为结果内的nick值
	user.setNickName(info.getString("nick"));
	//设置性别为结果内的gender值,有male,female,unknown三种属性
	user.setGender(info.getString("gender"));
	//设置生日
	user.setBirthday(birthday.getInt("year")+"-"+birthday.getInt("month")+"-"+birthday.getInt("day"));
	//设置vip级别
	user.setVipLevel(info.getInt("vip_info"));
	//获取自己的签名
	user.setPersonal(info.getString("lnick"));
	//设置自己的头像
	user.setLogo(logoUtil.getUserLogoByUin(info.getLong("account")));
	return user;
}
 
开发者ID:KittenDev,项目名称:WebQQAPI,代码行数:22,代码来源:Account.java

示例7: getUserGroup

import net.sf.json.JSONObject; //导入方法依赖的package包/类
/**
 * 获取组的信息
 * 
 * @param userGroupId
 *            组id
 * @param token
 *            身份
 * @return
 */
public static UserGroupData getUserGroup(String userGroupId, String token) {
	JSONObject js = new JSONObject();
	js.put("hOpCode", "3");
	js.put("userGroupId", userGroupId);
	Map<String, String> header = new HashMap<>();
	header.put("hOpCode", "3");
	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;
		}
		UserGroupData userGroup = new UserGroupData(returnjs.getJSONObject("userGroup"));
		return userGroup;
	}
	return null;
}
 
开发者ID:dianbaer,项目名称:anychat,代码行数:36,代码来源:IdentityAction.java

示例8: findMosaicFeeInformationByNIS

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

示例9: newInstance

import net.sf.json.JSONObject; //导入方法依赖的package包/类
@Override
public SQSScmConfig newInstance(StaplerRequest req, @Nonnull JSONObject jsonObject) throws FormException {
    JSONObject json = jsonObject.getJSONObject("type");
    json.put("type", json.getString("value"));
    json.remove("value");
    return super.newInstance(req, json);//req.bindJSON(SQSScmConfig.class, json);
}
 
开发者ID:riboseinc,项目名称:aws-codecommit-trigger-plugin,代码行数:8,代码来源:SQSScmConfig.java

示例10: findMosaicFeeInformationByNIS

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

示例11: configure

import net.sf.json.JSONObject; //导入方法依赖的package包/类
@Override
public boolean configure(StaplerRequest req, JSONObject json) throws hudson.model.Descriptor.FormException {
	json = json.getJSONObject("keycloak");
	keycloakJson = json.getString("keycloakJson");
	save();
	return true;
}
 
开发者ID:devlauer,项目名称:jenkins-keycloak-plugin,代码行数:8,代码来源:KeycloakSecurityRealm.java

示例12: configure

import net.sf.json.JSONObject; //导入方法依赖的package包/类
@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
    json = json.getJSONObject("config");
    webhookSecret = json.getString("webhookSecret");
    save();
    return true;
}
 
开发者ID:codeclou,项目名称:jenkins-github-webhook-build-trigger-plugin,代码行数:8,代码来源:GithubWebhookBuildTriggerPluginBuilder.java

示例13: sendStartTest

import net.sf.json.JSONObject; //导入方法依赖的package包/类
private JSONObject sendStartTest(String uri, int expectedRC) throws IOException {
    JSONObject response = httpUtils.queryObject(httpUtils.createPost(uri, ""), expectedRC);
    return response.getJSONObject("result");
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:5,代码来源:Test.java


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