當前位置: 首頁>>代碼示例>>Java>>正文


Java JSONObject.getIntValue方法代碼示例

本文整理匯總了Java中com.alibaba.fastjson.JSONObject.getIntValue方法的典型用法代碼示例。如果您正苦於以下問題:Java JSONObject.getIntValue方法的具體用法?Java JSONObject.getIntValue怎麽用?Java JSONObject.getIntValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.alibaba.fastjson.JSONObject的用法示例。


在下文中一共展示了JSONObject.getIntValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getQQUserinfo

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/**
 * 獲取QQ用戶信息
 * 
 * @param token
 * @param openid
 */
public static final ThirdPartyUser getQQUserinfo(String token, String openid) throws Exception {
	ThirdPartyUser user = new ThirdPartyUser();
	String url = Resources.THIRDPARTY.getString("getUserInfoURL_qq");
	url = url + "?format=json&access_token=" + token + "&oauth_consumer_key="
			+ Resources.THIRDPARTY.getString("app_id_qq") + "&openid=" + openid;
	String res = HttpUtil.httpClientPost(url);
	JSONObject json = JSONObject.parseObject(res);
	if (json.getIntValue("ret") == 0) {
		user.setUserName(json.getString("nickname"));
		String img = json.getString("figureurl_qq_2");
		if (img == null || "".equals(img)) {
			img = json.getString("figureurl_qq_1");
		}
		user.setAvatarUrl(img);
		String sex = json.getString("gender");
		if ("女".equals(sex)) {
			user.setGender("0");
		} else {
			user.setGender("1");
		}
	} else {
		throw new IllegalArgumentException(json.getString("msg"));
	}
	return user;
}
 
開發者ID:tb544731152,項目名稱:iBase4J,代碼行數:32,代碼來源:ThirdPartyLoginHelper.java

示例2: showCommandMessage

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
protected void showCommandMessage(CustomNotification message) {
    if (!isResume) {
        return;
    }

    String content = message.getContent();
    try {
        JSONObject json = JSON.parseObject(content);
        int id = json.getIntValue("id");
        if (id == 1) {
            // 正在輸入
            Toast.makeText(P2PMessageActivity.this, "對方正在輸入...", Toast.LENGTH_LONG).show();
        } else {
            Toast.makeText(P2PMessageActivity.this, "command: " + content, Toast.LENGTH_SHORT).show();
        }

    } catch (Exception e) {

    }
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:21,代碼來源:P2PMessageActivity.java

示例3: fromJSON

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/**
 * 從對應的json字符轉換成JResponse
 *
 * @param json
 * @return
 * @throws JResponseFormatException
 */
public static JResponse fromJSON(String json) throws JResponseFormatException
{
    try
    {
        JSONObject jsonObject = JSON.parseObject(json);
        int code = jsonObject.getIntValue(CODE_FIELD);
        String desc = getString(jsonObject, DESCRIPTION_FIELD);

        Object result = getResult(jsonObject);
        Object extra = getExtra(jsonObject);

        JResponse jsonResponse = new JResponse();
        jsonResponse.setCode(ResultCode.toResponseCode(code));
        jsonResponse.setDescription(desc);
        jsonResponse.setResult(result);
        jsonResponse.setExtra(extra);
        return jsonResponse;
    } catch (Exception e)
    {
        throw new JResponseFormatException(e);
    }
}
 
開發者ID:gzxishan,項目名稱:OftenPorter,代碼行數:30,代碼來源:JResponse.java

示例4: encode

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
@Override
public Object encode(DbusMessage.Field field, Object value, EncodeColumn col) {
    if (field.dataType() == DataType.STRING) {
        /*
        脫敏需要預處理時,輸入框輸入的是json串,例如{regex:"^[\\u4e00-\\u9fa5]{1,4}$",replaceStr:"某某",encode:1,saltParam:"8975608a345ce784d09b6ce1479722b4"}
        regex是預處理使用的正則表達式,replaceStr為用於替換的字符串,encode取值為1或0,若為1,則預處理後需再脫敏,為0,隻是進行預處理
        saltParam為脫敏的鹽值
         */
        JSONObject jsonValue = JSON.parseObject(col.getEncodeParam());
        if(jsonValue.getIntValue("encode") == 1){
            return value == null ? value : md5RegexHandle(value,jsonValue);
        }else{
            return value == null ? value : regexHandle(value.toString(),jsonValue.getString("regex"),jsonValue.getString
                    ("replaceStr"));
        }
    }
    return value;
}
 
開發者ID:BriData,項目名稱:DBus,代碼行數:19,代碼來源:RegexNormalizerEncoder.java

示例5: getDataObj

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/**
 * 獲取返回對象中的data對象,需要SOA響應狀態碼是0
 *
 * @param result
 * @return
 * @author xuxiao
 * @created 2014年5月9日 上午11:22:17
 */
public static JSONObject getDataObj(final String result) {
    final JSONObject obj = getJsonObj(result);
    JSONObject data = null;
    if (null != obj
            && (DataTransferObject.BUS_SUCCESS == obj.getIntValue("code") || DataTransferObject.SUCCESS == obj.getIntValue("code"))
            && obj.containsKey("data")) {
        data = obj.getJSONObject("data");
    }
    return data;
}
 
開發者ID:AsuraTeam,項目名稱:asura,代碼行數:19,代碼來源:SOAResParseUtil.java

示例6: getConnectUser

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
@Override
public OAuthConnectUser getConnectUser(String code) throws Exception {
    OAuthConnectUser _connectUser = __doGetAccessToken(code, __TOKEN_URL);
    if (_connectUser != null) {
        if (StringUtils.isNotBlank(_connectUser.getAccessToken()) && StringUtils.isNotBlank(_connectUser.getOpenId())) {
            Map<String, String> _params = new HashMap<String, String>();
            _params.put("access_token", _connectUser.getAccessToken());
            _params.put("openid", _connectUser.getOpenId());
            //
            IHttpResponse _response = HttpClientHelper.create().get(__USERINFO_URL, _params);
            JSONObject _result = __doParseConnectResponseBody(_response);
            if (_result != null) {
                _connectUser.setNickName(_result.getString("nickname"))
                        .setPhotoUrl(_result.getString("headimgurl"))
                        .setUnionId(_result.getString("unionid"));
                switch (_result.getIntValue("sex")) {
                    case 1:
                        _connectUser.setGender(OAuthConnectUser.Gender.MALE);
                        break;
                    case 2:
                        _connectUser.setGender(OAuthConnectUser.Gender.FEMALE);
                        break;
                    default:
                        _connectUser.setGender(OAuthConnectUser.Gender.UNKNOW);
                }
                //
                _connectUser.putAttribute("country", _result.getString("country"));
                _connectUser.putAttribute("province", _result.getString("province"));
                _connectUser.putAttribute("city", _result.getString("city"));
            }
        }
    }
    return _connectUser;
}
 
開發者ID:suninformation,項目名稱:ymate-module-oauth-connector,代碼行數:35,代碼來源:WeChatConnectProcessor.java

示例7: isSuccess

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/**
 * 判斷是否請求成功
 *
 * @param resultStr
 * @throws WeChatException
 */
public static void isSuccess(String resultStr) throws WeChatException {
	JSONObject jsonObject = JSONObject.parseObject(resultStr);
	Integer errCode = jsonObject.getIntValue("errcode");
	if (errCode != null && errCode != 0) {
		String errMsg = WeChatReturnCode.getMsg(errCode);
		if (errMsg.equals("")) {
			errMsg = jsonObject.getString("errmsg");
		}
		throw new WeChatException("異常碼:" + errCode + ";異常說明:" + errMsg);
	}
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:18,代碼來源:WeChatUtil.java

示例8: updateKfAccount

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/**
 * 修改客服帳號
 *
 * @param keFu
 * @return
 */
public static boolean updateKfAccount(KeFu keFu) {
    boolean isOk = false;
    String token = WeiXinUtils.getToken();
    if (token != null) {
        String urlString = "https://api.weixin.qq.com/customservice/kfaccount/update?access_token=" + token;
        try {
            URL url = new URL(urlString);
            HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection();
            String kfAccountString = JSONObject.toJSONString(keFu);
            httpsURLConnection.setRequestProperty("Content-length", String.valueOf(kfAccountString.length()));
            httpsURLConnection.setRequestProperty("Content-Type", "application/json");
            httpsURLConnection.setDoOutput(true);
            httpsURLConnection.setDoInput(true);
            DataOutputStream dataOutputStream = new DataOutputStream(httpsURLConnection.getOutputStream());
            dataOutputStream.write(kfAccountString.getBytes());
            dataOutputStream.flush();
            dataOutputStream.close();
            DataInputStream dataInputStream = new DataInputStream(httpsURLConnection.getInputStream());
            StringBuffer stringBuffer = new StringBuffer();
            int inputByte = dataInputStream.read();
            while (inputByte != -1) {
                stringBuffer.append((char) inputByte);
                inputByte = dataInputStream.read();
            }
            String kfString = stringBuffer.toString();
            JSONObject jsonObject = JSON.parseObject(kfString);
            if (jsonObject.containsKey("errcode")) {
                int errcode = jsonObject.getIntValue("errcode");
                if (errcode == 0) {
                    isOk = true;
                } else {
                    //TODO 添加客服賬號失敗
                    isOk = false;
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    return isOk;
}
 
開發者ID:guokezheng,項目名稱:automat,代碼行數:48,代碼來源:WeiXinKFUtils.java

示例9: deleteKfAccount

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/**
 * 刪除客服帳號
 *
 * @param keFu
 * @return
 */
public static boolean deleteKfAccount(KeFu keFu) {
    boolean isOk = false;
    String token = WeiXinUtils.getToken();
    if (token != null) {
        String urlString = "https://api.weixin.qq.com/customservice/kfaccount/del?access_token=" + token;
        try {
            URL url = new URL(urlString);
            HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection();
            String kfAccountString = JSONObject.toJSONString(keFu);
            httpsURLConnection.setRequestProperty("Content-length", String.valueOf(kfAccountString.length()));
            httpsURLConnection.setRequestProperty("Content-Type", "application/json");
            httpsURLConnection.setDoOutput(true);
            httpsURLConnection.setDoInput(true);
            DataOutputStream dataOutputStream = new DataOutputStream(httpsURLConnection.getOutputStream());
            dataOutputStream.write(kfAccountString.getBytes());
            dataOutputStream.flush();
            dataOutputStream.close();
            DataInputStream dataInputStream = new DataInputStream(httpsURLConnection.getInputStream());
            StringBuffer stringBuffer = new StringBuffer();
            int inputByte = dataInputStream.read();
            while (inputByte != -1) {
                stringBuffer.append((char) inputByte);
                inputByte = dataInputStream.read();
            }
            String kfString = stringBuffer.toString();
            JSONObject jsonObject = JSON.parseObject(kfString);
            if (jsonObject.containsKey("errcode")) {
                int errcode = jsonObject.getIntValue("errcode");
                if (errcode == 0) {
                    isOk = true;
                } else {
                    //TODO 添加客服賬號失敗
                    isOk = false;
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    return isOk;
}
 
開發者ID:tb544731152,項目名稱:iBase4J,代碼行數:48,代碼來源:WeiXinKFUtils.java

示例10: getConfig

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
private static StatusBarNotificationConfig getConfig(String key) {
    StatusBarNotificationConfig config = new StatusBarNotificationConfig();
    String jsonString = getSharedPreferences().getString(key, "");
    try {
        JSONObject jsonObject = JSONObject.parseObject(jsonString);
        if (jsonObject == null) {
            return null;
        }
        config.downTimeBegin = jsonObject.getString("downTimeBegin");
        config.downTimeEnd = jsonObject.getString("downTimeEnd");
        config.downTimeToggle = jsonObject.getBoolean("downTimeToggle");
        config.ring = jsonObject.getBoolean("ring");
        config.vibrate = jsonObject.getBoolean("vibrate");
        config.notificationSmallIconId = jsonObject.getIntValue("notificationSmallIconId");
        config.notificationSound = jsonObject.getString("notificationSound");
        config.hideContent = jsonObject.getBoolean("hideContent");
        config.ledARGB = jsonObject.getIntValue("ledargb");
        config.ledOnMs = jsonObject.getIntValue("ledonms");
        config.ledOffMs = jsonObject.getIntValue("ledoffms");
        config.titleOnlyShowAppName = jsonObject.getBoolean("titleOnlyShowAppName");
        config.notificationFolded = jsonObject.getBoolean("notificationFolded");
        config.notificationEntrance = (Class<? extends Activity>) Class.forName(jsonObject.getString("notificationEntrance"));
        config.notificationColor = jsonObject.getInteger("notificationColor");
    } catch (Exception e) {
        e.printStackTrace();
    }

    return config;
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:30,代碼來源:UserPreferences.java

示例11: getReturnCode

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/**
 * 獲取返回JSON對象的響應狀態碼
 *
 * @param result
 * @return
 * @author xuxiao
 * @created 2014年5月7日 下午6:01:09
 */
public static int getReturnCode(final String result) {
    LOGGER.debug("return code,result:{}", result);
    final JSONObject json = getJsonObj(result);
    if (null != json && json.containsKey("code")) {
        return json.getIntValue("code");
    } else {
        return -1;
    }
}
 
開發者ID:AsuraTeam,項目名稱:asura,代碼行數:18,代碼來源:SOAResParseUtil.java

示例12: GetListByJson

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
private static List<SongResult> GetListByJson(JSONArray songs) throws Exception {
        List<SongResult> list = new ArrayList<>();
        int len = songs.size();
        if (len <= 0) {
            return null;
        }
        int i = 0;
        while (i < len) {
            SongResult songResult = new SongResult();

            JSONObject songsBean = songs.getJSONObject(i);
            String SongId = songsBean.getString("hash");
            String SongName = songsBean.getString("songname");
            String AlbumId = songsBean.getString("album_id");
            String AlbumName = songsBean.getString("album_name").replace("+", ";");
            String artistName = songsBean.getString("singername").replace("+", ";");
            int length = songsBean.getIntValue("duration");
            songResult.setArtistName(artistName);
            songResult.setSongId(SongId);
            songResult.setSongName(SongName);
            songResult.setLength(Util.secTotime(length));
            if (!AlbumId.isEmpty() && Util.isNumber(AlbumId)) {
                songResult.setPicUrl(GetUrl(AlbumId, "320", "jpg"));
            } else {
                songResult.setPicUrl(GetUrl(SongId, "320", "jpg"));
            }
            String s20hash = songsBean.getString("320hash");
            String sqHash = songsBean.getString("sqhash");
            if (!s20hash.isEmpty()) {
                songResult.setBitRate("320K");
                String sq = GetUrl(s20hash, "320", "mp3");
                songResult.setSqUrl(sq);
                if (songResult.getHqUrl().isEmpty()) {
                    songResult.setHqUrl(sq);
                }
            }
            if (!sqHash.isEmpty()) {
                songResult.setBitRate("無損");
                songResult.setFlacUrl(GetUrl(sqHash, "1000", "mp3"));
            }
            if (!SongId.isEmpty()) {
                songResult.setBitRate("128K");
                songResult.setLqUrl(GetUrl(SongId, "128", "mp3"));
            }
//            GetUrl(songsBean.getValue320hash(),"320","mp3");
//            String Songlink = "http://h.dongting.com/yule/app/music_player_page.html?id=" + String.valueOf(songsBean.getSongId());
//            songResult.setSongLink(Songlink);
            String mvHash = songsBean.getString("mvhash");
            if (!mvHash.isEmpty()) {
                songResult.setMvId(mvHash);
                songResult.setMvHdUrl(GetUrl(mvHash, "hd", "mp4"));
                songResult.setMvLdUrl(GetUrl(mvHash, "ld", "mp4"));
            }
            songResult.setAlbumId(AlbumId);
            songResult.setAlbumName(AlbumName);

            songResult.setType("kg");
//            songResult.setPicUrl(songsBean.getPicUrl());
//            GetUrl(SongId,"320","lrc");
//            songResult.setLrcUrl(GetLrcUrl(SongId, SongName, artistName)); //暫不去拿歌曲,直接解析浪費性能

            list.add(songResult);
            i++;
        }
        return list;
    }
 
開發者ID:Qrilee,項目名稱:MusicuuApi,代碼行數:67,代碼來源:KgMusic.java

示例13: convertResponse

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
private static boolean convertResponse(HttpEntity response) throws IOException {
    String strResponse = EntityUtils.toString(response);
    JSONObject jsonResponse = JSONObject.parseObject(strResponse);
    return jsonResponse.containsKey("errcode") && jsonResponse.getIntValue("errcode") == 0;
}
 
開發者ID:justice-code,項目名稱:Thrush,代碼行數:6,代碼來源:ImHttpRequest.java

示例14: read

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
@Override
public Object read(Field field, JDataInput jDataInput, Object... others) throws IOException
{

	SimpleLengthRule rule = field.getSimpleLengthRule();

	JSONObject result = (JSONObject) others[0];

	int packageLength = result.getIntValue(rule.getFileName());

	byte[] waveData = new byte[rule.getRule().getIntValue(packageLength, rule.getValue().intValue()).intValue()];

	jDataInput.readByteArray(waveData);

	return waveData;
}
 
開發者ID:yanghao0518,項目名稱:cstruct-parser,代碼行數:17,代碼來源:ByteArrayJFieldOpt.java

示例15: build

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
public LogFilterAndRule build(String classname) {

            // get serverid
            serverid = Preconditions.checkNotNull(serverid, "serverid must be set...");
            // get appid
            appid = Preconditions.checkNotNull(appid, "appid must be set...");
            // get logid
            logid = Preconditions.checkNotNull(logid, "logid must be set...");
            // get rule json
            rule = Optional.fromNullable(rule).or(DEFAULT_RULE);
            // parse filter json
            String filterregex = Optional.fromNullable(filter).or(DEFAULT_FILTER_PREFIX);
            // parse rule json
            JSONObject robject = JSON.parseObject(rule);
            String separator = Optional.fromNullable(robject.getString("separator")).or("\t");
            JSONObject assignFields = Optional.fromNullable(robject.getJSONObject("assignfields"))
                    .or(DEFAULT_ASSIGNFIELDS);
            // Verify timeStamp number is available
            int timestampNumber = robject.getIntValue("timestamp");
            // build by reflect
            LogFilterAndRule mainLogFAR = (LogFilterAndRule) ReflectionHelper.newInstance(
                    "com.creditease.agent.feature.logagent.far." + classname + "LogFilterAndRule",
                    new Class[] { String.class, String.class, JSONObject.class, int.class, int.class },
                    new Object[] { filterregex, separator, assignFields, timestampNumber, version },
                    ConfigurationManager.getInstance().getFeatureClassLoader("logagent"));
            // LogFilterAndRule mainLogFAR = new DefaultLogFilterAndRule(filterregex, separator, assignFields,
            // timestampNumber);
            LogFilterAndRule aid = null;
            List<LogFilterAndRule> aidLogFARlist = null;
            if (aids != null && aids.length > 0) {
                aidLogFARlist = Lists.newArrayList();
                for (String name : aids) {
                    aid = (LogFilterAndRule) ReflectionHelper
                            .newInstance("com.creditease.agent.feature.logagent.far." + name + "LogFilterAndRule");
                    aidLogFARlist.add(aid);
                }

            }
            LogAgent logAgent = (LogAgent) ConfigurationManager.getInstance().getComponent("logagent", "LogAgent");
            AppLogPatternInfoCollection profileMap = logAgent.getLatestLogProfileDataMap();
            LogPatternInfo logPatternInfo = profileMap.get(serverid + "-" + appid,
                    serverid + "-" + appid + "-" + logid);
            pubLogFilterAndRule(logPatternInfo.getAbsolutePath(), mainLogFAR);
            if (aidLogFARlist != null) {
                pubAidLogFilterAndRule(logPatternInfo.getAbsolutePath(), aidLogFARlist);
            }
            return mainLogFAR;
        }
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:49,代碼來源:RuleFilterFactory.java


注:本文中的com.alibaba.fastjson.JSONObject.getIntValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。