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