本文整理汇总了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";
}
示例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;
}
示例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;
}
示例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;
}
示例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");
}
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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");
}