當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。