本文整理汇总了Java中net.sf.json.JSONObject.getInt方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.getInt方法的具体用法?Java JSONObject.getInt怎么用?Java JSONObject.getInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.json.JSONObject
的用法示例。
在下文中一共展示了JSONObject.getInt方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: UserData
import net.sf.json.JSONObject; //导入方法依赖的package包/类
public UserData(JSONObject userData) {
if (userData.containsKey("userId")) {
this.userId = userData.getString("userId");
}
if (userData.containsKey("userRealName")) {
this.userRealName = userData.getString("userRealName");
}
if (userData.containsKey("userGroupTopId")) {
this.userGroupTopId = userData.getString("userGroupTopId");
}
if (userData.containsKey("userRole")) {
this.userRole = userData.getInt("userRole");
}
if (userData.containsKey("userImgUrl")) {
this.userImgUrl = userData.getString("userImgUrl");
}
}
示例2: getOauth2Token
import net.sf.json.JSONObject; //导入方法依赖的package包/类
/**
* 获取网页授权凭证
* @param appId
* @param appSecret
* @param code
* @return
*/
public Oauth2Token getOauth2Token(String appId,String appSecret,String code){
Oauth2Token oauth2Token = null;
String requestUrl = access_token_url.replace("APPID", appId).replace("SECRET", appSecret).replace("CODE", code);
logger.info("getOauth2Token => ###### requestUrl : " + requestUrl);
JSONObject jsonObject = CommonUtil.httpsRequest(requestUrl, "GET", null);
if(null != jsonObject){
try{
oauth2Token = new Oauth2Token();
oauth2Token.setAccessToken(jsonObject.getString("access_token"));
oauth2Token.setExpiresIn(jsonObject.getInt("expires_in"));
oauth2Token.setRefreshToken(jsonObject.getString("refresh_token"));
oauth2Token.setOpenId(jsonObject.getString("openid"));
oauth2Token.setScope(jsonObject.getString("scope"));
}catch(Exception e){
oauth2Token = null;
int errCode = jsonObject.getInt("errcode");
String errMsg = jsonObject.getString("errmsg");
logger.error("获取网页授权凭证失败 errCode : {} , errmsg : {} ", errCode,errMsg);
}
}
logger.info("getOauth2Token => 返回 :" + com.alibaba.fastjson.JSONObject.toJSONString(oauth2Token));
return oauth2Token;
}
示例3: refreshOauth2Token
import net.sf.json.JSONObject; //导入方法依赖的package包/类
/**
* 刷新网页授权凭证
* @param appId
* @param appSecret
* @param code
* @return
*/
public Oauth2Token refreshOauth2Token(String appId,String refreshToken){
logger.info("refreshOauth2Token appId : {} , refreshToken : {} ", appId, refreshToken);
Oauth2Token oauth2Token = null;
String requestUrl = refresh_token_url.replace("APPID", appId).replace("REFRESH_TOKEN", refreshToken);
JSONObject jsonObject = CommonUtil.httpsRequest(requestUrl, "GET", null);
if(null != jsonObject){
try{
oauth2Token = new Oauth2Token();
oauth2Token.setAccessToken(jsonObject.getString("access_token"));
oauth2Token.setExpiresIn(jsonObject.getInt("expires_in"));
oauth2Token.setRefreshToken(jsonObject.getString("refresh_token"));
oauth2Token.setOpenId(jsonObject.getString("openid"));
oauth2Token.setScope(jsonObject.getString("scope"));
}catch(Exception e){
oauth2Token = null;
int errCode = jsonObject.getInt("errcode");
String errMsg = jsonObject.getString("errmsg");
logger.error("刷新网页授权凭证失败 errCode : {} , errmsg : {} ", errCode,errMsg);
}
}
logger.info("refreshOauth2Token => 返回 :" + com.alibaba.fastjson.JSONObject.toJSONString(oauth2Token));
return oauth2Token;
}
示例4: createMenu
import net.sf.json.JSONObject; //导入方法依赖的package包/类
/**
* 创建菜单
*
* @param menu
* 菜单实例
* @param accessToken
* 有效的access_token
* @return 0表示成功,其他值表示失败
*/
public static int createMenu(Menu menu, String accessToken) {
int result = 0;
// 拼装创建菜单的url
String url = menu_create_url.replace("ACCESS_TOKEN", accessToken);
// 将菜单对象转换成json字符串
String jsonMenu = JSONObject.fromObject(menu).toString();
// 调用接口创建菜单
JSONObject jsonObject = CommonUtil.httpsRequest(url, "POST", jsonMenu);
if (null != jsonObject) {
if (0 != jsonObject.getInt("errcode")) {
result = jsonObject.getInt("errcode");
logger.error("创建菜单失败 errcode:{} errmsg:{}", jsonObject.getInt("errcode"), jsonObject.getString("errmsg"));
}
}
return result;
}
示例5: upload
import net.sf.json.JSONObject; //导入方法依赖的package包/类
@Override
public String upload(byte[] data, String path) {
//腾讯云必需要以"/"开头
if(!path.startsWith("/")) {
path = "/" + path;
}
//上传到腾讯云
UploadFileRequest request = new UploadFileRequest(config.getQcloudBucketName(), path, data);
String response = client.uploadFile(request);
JSONObject jsonObject = JSONObject.fromObject(response);
if(jsonObject.getInt("code") != 0) {
throw new RRException("文件上传失败," + jsonObject.getString("message"));
}
return config.getQcloudDomain() + path;
}
示例6: paserString2Address
import net.sf.json.JSONObject; //导入方法依赖的package包/类
/**
* 获取AddressInfo对象
*
* @param address
* @return
*/
private static AddressInfo paserString2Address(String address) {
if ("".equals(address.trim()) || null == address) {
return null;
}
AddressInfo info = new AddressInfo();
JSONObject obj = JSONObject.fromObject(address);
if (1 == obj.getInt("code")) {
return null;
}
JSONObject infoObj = JSONObject.fromObject(obj.get("data"));
info.setCountry(infoObj.getString("country"));
info.setArea(infoObj.getString("area"));
info.setRegion(infoObj.getString("region"));
info.setCity(infoObj.getString("city"));
info.setIsp(infoObj.getString("isp"));
return info;
}
示例7: upload
import net.sf.json.JSONObject; //导入方法依赖的package包/类
@Override
public String upload(byte[] data, String path) {
//腾讯云必需要以"/"开头
if (!path.startsWith("/")) {
path = "/" + path;
}
//上传到腾讯云
UploadFileRequest request = new UploadFileRequest(config.getQcloudBucketName(), path, data);
String response = client.uploadFile(request);
JSONObject jsonObject = JSONObject.fromObject(response);
if (jsonObject.getInt("code") != 0) {
throw new RRException("文件上传失败," + jsonObject.getString("message"));
}
return config.getQcloudDomain() + path;
}
示例8: getUserInfo
import net.sf.json.JSONObject; //导入方法依赖的package包/类
@SuppressWarnings({ "deprecation", "unchecked" })
public SNSUserInfo getUserInfo(String accessToken,String openId){
logger.info("getUserInfo accessToken : {} , openId : {} ", accessToken, openId);
SNSUserInfo user = null;
String requestUrl = userinfo_url.replace("OPENID", openId).replace("ACCESS_TOKEN", accessToken);
JSONObject jsonObject = CommonUtil.httpsRequest(requestUrl, "GET", null);
if(null != jsonObject){
// logger.info("授权返回JSONObject 数据 : " + com.meidusa.fastjson.JSONObject.toJSONString(jsonObject));
logger.info("授权返回JSONObject 数据 : Key : {}, values : {} " ,com.alibaba.fastjson.JSONObject.toJSONString(jsonObject.keySet()),
com.alibaba.fastjson.JSONObject.toJSONString(jsonObject.values()));
try{
user = new SNSUserInfo();
user.setOpenId(jsonObject.getString("openid"));
user.setNickname(jsonObject.getString("nickname"));
user.setSex(jsonObject.getInt("sex"));
user.setProvince(jsonObject.getString("province"));
user.setCity(jsonObject.getString("city"));
user.setCountry(jsonObject.getString("country"));
user.setHeadimgurl(jsonObject.getString("headimgurl"));
user.setPrivilegeList(JSONArray.toList(jsonObject.getJSONArray("privilege"), List.class));
}catch(Exception e){
logger.error("网页授权获取用户信息失败 " + e.getMessage());
user = null;
int errCode = jsonObject.getInt("errcode");
String errMsg = jsonObject.getString("errmsg");
logger.error("网页授权获取用户信息失败 errCode : {} , errmsg : {} ", errCode,errMsg);
}
}
logger.info("getUserInfo => 返回 : " + com.alibaba.fastjson.JSONObject.toJSONString(user));
return user;
}
示例9: configure
import net.sf.json.JSONObject; //导入方法依赖的package包/类
@Override
public boolean configure(StaplerRequest staplerRequest, JSONObject json) throws FormException {
// to persist global configuration information,
// set that to properties and call save().
//System.out.println(json.toString());
if(json.containsKey("logPollingFreq")) {
logPollingFreq = json.getInt("logPollingFreq");
}
else {
logPollingFreq = 15;
}
save();
return true; // indicate that everything is good so far
}
示例10: isValid
import net.sf.json.JSONObject; //导入方法依赖的package包/类
public boolean isValid(){
JSONObject r=new JSONObject();
r.put("ptwebqq",ptwebqq);
r.put("clientid",53999199);
r.put("psessionid","");
r.put("status","online");
Response loginResult=new HttpUtils().post(URL.URL_LOGIN,new PostParameter[]{new PostParameter("r",r.toString())},new HttpHeader[]{cookie});
JSONObject result=JSONObject.fromObject(JSONObject.fromObject(loginResult.getContent("UTF-8")));
if(result.getInt("retcode")==0){
return true;
}else{
return false;
}
}
示例11: monitorCosignUnconfirmed
import net.sf.json.JSONObject; //导入方法依赖的package包/类
/**
* monitor multisig unconfirmed (cosign)
* @param result
* @return
*/
private void monitorCosignUnconfirmed(String result){
JSONObject json = null;
try {
json = JSONObject.fromObject(result);
} catch (Exception ex) {
return;
}
if(!json.containsKey("otherHash")
|| !json.containsKey("otherAccount")
|| json.getLong("type")!=Constants.TX_TYPE_COSIGN_MULTISIG){
return;
}
long timeStamp = json.getLong("timeStamp");
String innerTransactionHash = json.getJSONObject("otherHash").getString("data");
String otherAccount = json.getString("otherAccount");
String cosignAddress = KeyConvertor.getAddressFromPublicKey(json.getString("signer"));
if(!otherAccount.equals(this.address)){
return;
}
if(!outCosignedMap.containsKey(innerTransactionHash)){
return;
}
JSONObject outJSON = outCosignedMap.get(innerTransactionHash);
JSONObject outCosignAccount = new JSONObject();
JSONArray outCosignAccountArray = outJSON.getJSONArray("cosignAccount");
outCosignAccount.put("address", cosignAddress);
outCosignAccount.put("date", DateUtils.nemToRealDateStr(timeStamp));
outCosignAccountArray.add(outCosignAccount);
if(outCosignAccountArray.size()>=outJSON.getInt("minCosignatories")){
outCosignedMap.remove(innerTransactionHash);
return;
}
JSONArray outUnsignedAccountArray = outJSON.getJSONArray("unsignedAccount");
int removeIndex = -1;
for(int i=0;i<outUnsignedAccountArray.size();i++){
if(outUnsignedAccountArray.getJSONObject(i).getString("address").equals(cosignAddress)){
removeIndex = i;
break;
}
}
if(removeIndex!=-1) {
outUnsignedAccountArray.remove(removeIndex);
}
outJSON.put("cosignAccount", outCosignAccountArray);
outJSON.put("unsignedAccount", outUnsignedAccountArray);
outCosignedMap.put(innerTransactionHash, outJSON);
System.out.println(outJSON.toString());
}
示例12: sendOnlineData
import net.sf.json.JSONObject; //导入方法依赖的package包/类
public void sendOnlineData(JSONObject data) throws IOException {
JSONObject session = test.getSession().sendData(data);
int statusCode = session.getInt("statusCode");
if (statusCode > 100) {
notifier.notifyAbout("Test was stopped through Web UI: " + session.getString("status"));
throw new JMeterStopTestException("The test was interrupted through Web UI");
}
}