本文整理匯總了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");
}
}