当前位置: 首页>>代码示例>>Java>>正文


Java JSONObject.getLong方法代码示例

本文整理汇总了Java中net.sf.json.JSONObject.getLong方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.getLong方法的具体用法?Java JSONObject.getLong怎么用?Java JSONObject.getLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.json.JSONObject的用法示例。


在下文中一共展示了JSONObject.getLong方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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";
}
 
开发者ID:NEMChina,项目名称:nem-apps,代码行数:32,代码来源:ImplInitMultisigTransaction.java

示例2: getDiscussUsers

import net.sf.json.JSONObject; //导入方法依赖的package包/类
public ArrayList<User> getDiscussUsers(){
	ArrayList<User> users=new ArrayList<User>();
	//用这个讨论组的did,以及vfwebqq合成一个完整的URL,并且将结果解析为json对象
	String url=URL.URL_GET_DISCUSS_INFO.replace("[var]",Long.toString(discussID)).replace("[var1]",credential.getVfWebQQ()).replace("[var2]",credential.getPsessionID());
	String info=utils.get(url,new HttpHeader[]{URL.URL_MESSAGE_REFERER,credential.getCookie()}).getContent("UTF-8");
	JSONObject result=JSONObject.fromObject(info).getJSONObject("result");
	//获取用户信息
	JSONArray usersInfo=result.getJSONArray("mem_info");
	//获取在线状态
	JSONArray usersStatus=result.getJSONArray("mem_status");
	//设置昵称,状态以及uin
	int tempIndex=0;
	for(int i=0;i<usersInfo.size();i++){
		JSONObject tempUserInfo=JSONObject.fromObject(usersInfo.get(i));
		User tempUser=new User(tempUserInfo.getLong("uin"));
		tempUser.setNickName(tempUserInfo.getString("nick"));
		if(tempIndex<usersStatus.size()&&tempUser.getUID()==JSONObject.fromObject(usersStatus.get(tempIndex)).getLong("uin")){
			tempUser.setOnlineStatus(true);
			tempIndex++;
	}
		users.add(tempUser);
	}
	return users;
	
}
 
开发者ID:KittenDev,项目名称:WebQQAPI,代码行数:26,代码来源:Discuss.java

示例3: 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;
}
 
开发者ID:KittenDev,项目名称:WebQQAPI,代码行数:22,代码来源:Account.java

示例4: getDiscussList

import net.sf.json.JSONObject; //导入方法依赖的package包/类
public ArrayList<Discuss> getDiscussList(){
	ArrayList<Discuss> discussesList=new ArrayList<Discuss>();
	//用psessionid合成一个完整的URL并且访问它,并将结果解析为json
	JSONObject result=JSONObject.fromObject(utils.get(URL.URL_GET_DISCUSS_LIST.replace("[var]",credential.getPsessionID()).replace("[var1]",credential.getVfWebQQ()),new HttpHeader[]{URL.URL_REFERER,credential.getCookie()}).getContent("UTF-8")).getJSONObject("result");
	//获取讨论组列表
	JSONArray discussesListInfo=result.getJSONArray("dnamelist");
	//构造讨论组列表
	for(int i=0;i<discussesListInfo.size();i++){
		JSONObject tempDiscussInfo=JSONObject.fromObject(discussesListInfo.get(i));
		//取出讨论组id,构造一个讨论组,credential用于获取成员列表
		Discuss tempDiscuss=new Discuss(tempDiscussInfo.getLong("did"),credential);
		//设置讨论组的名称
		tempDiscuss.setName(tempDiscussInfo.getString("name"));
		//添加到list内
		discussesList.add(tempDiscuss);
	}
	return discussesList;
}
 
开发者ID:KittenDev,项目名称:WebQQAPI,代码行数:19,代码来源:Account.java

示例5: getGroupList

import net.sf.json.JSONObject; //导入方法依赖的package包/类
public ArrayList<Group> getGroupList(){
	ArrayList<Group> groupsList=new ArrayList<Group>();
	JSONObject r=new JSONObject();
	r.put("vfwebqq",credential.getVfWebQQ());
	r.put("hash",credential.getHash());
	//构造一个请求表单,用于获取群列表
	
	//访问获取群信息的链接,并将结果解析为json
	JSONObject result=JSONObject.fromObject(utils.post(URL.URL_GET_GROUP_LIST,new PostParameter[]{new PostParameter("r",r.toString())},new HttpHeader[]{URL.URL_REFERER,credential.getCookie()}).getContent("UTF-8")).getJSONObject("result");
	//从结果取出群列表
	JSONArray groups=result.getJSONArray("gnamelist");
	//构造群对象
	for(int i=0;i<groups.size();i++){
		JSONObject tempInfo=JSONObject.fromObject(groups.get(i));
		//构造一个群对象,gid为群id,gcode用于获取成员,credential用于获取成员列表
		Group tempGroup=new Group(tempInfo.getLong("gid"),tempInfo.getLong("code"),credential);
		//设置群的名称
		tempGroup.setName(tempInfo.getString("name"));
		groupsList.add(tempGroup);
	}
	return groupsList;
}
 
开发者ID:KittenDev,项目名称:WebQQAPI,代码行数:23,代码来源:Account.java

示例6: getCredential

import net.sf.json.JSONObject; //导入方法依赖的package包/类
public static Credential getCredential(String url,HttpHeader cookies){
	HttpUtils util=new HttpUtils();
	//必须设置不跟随重定向,否则无法取得cookies
	util.setGetFollowRedirect(false);
	//访问302跳转的url
	Response response=util.get(url);
	StringBuffer cookie=new StringBuffer();
	//取出cookies
	ArrayList<HttpHeader> headers=response.getHeaders();
	String[] cookieArray=cookies.getValue().split(" ");
	String ptwebqq=null;
	for(int i=0;i<cookieArray.length;i++){
		//获取ptwebqq
		if(cookieArray[i].contains("ptwebqq")){
			ptwebqq=cookieArray[i].substring(cookieArray[i].indexOf("=")+1,cookieArray[i].indexOf(";"));
			break;
		}
	}
	//在cookies内添加ptwebqq项
	cookie.append("ptwebqq="+ptwebqq+"; ");
	for(int i=0;i<headers.size();i++){
		if(headers.get(i).getHeader()==null){
			continue;
		}
		if(headers.get(i).getHeader().equals("Set-Cookie")){
		String temp=headers.get(i).getValue().substring(0,headers.get(i).getValue().indexOf(";")+1);
		//判断每一项cookie的值是否为空,如果等于号后面直接就是分号结尾,那就是空值,需要过滤
		if(!temp.substring(temp.indexOf("=")+1,temp.length()).equals(";")){
		cookie.append(temp+" ");
		}
		}
	}
	//生成一个登录表单
	JSONObject r=new JSONObject();
	r.put("ptwebqq",ptwebqq);
	r.put("clientid",53999199);
	r.put("psessionid","");
	r.put("status","online");
	//访问登录链接,需要带上前面的cookies访问
	Response loginResult=util.post(URL.URL_LOGIN,new PostParameter[]{new PostParameter("r",r.toString())},new HttpHeader[]{new HttpHeader("Cookie",cookie.toString())});
	JSONObject result=JSONObject.fromObject(JSONObject.fromObject(loginResult.getContent("UTF-8")));
	JSONObject data=JSONObject.fromObject(result.get("result"));
	//获取自己的uin
	long uin=data.getLong("uin");
	//获取psessionid,这个在收发消息需要用到
	String psessionid=data.getString("psessionid");
	//获取vfwebqq,必须带上Referer和前面的cookies
	String vfwebqq_temp=util.get(URL.URL_GET_VFWEBQQ,new HttpHeader[]{URL.URL_REFERER,new HttpHeader("Cookie",cookie.toString())}).getContent("UTF-8");
	//将结果解析为JSON对象
	JSONObject result_jsonObj=JSONObject.fromObject(vfwebqq_temp);
	//构造一个凭据对象,将获取到的数据全部传入
	Credential credential=new Credential(uin,result_jsonObj.getJSONObject("result").getString("vfwebqq"),psessionid,ptwebqq,new HttpHeader("Cookie",cookie.toString()));
	//返回码,这个可有可无,无所谓
	credential.setRetcode(result.getInt("retcode"));
	return credential;
}
 
开发者ID:KittenDev,项目名称:WebQQAPI,代码行数:57,代码来源:QrcodeLogin.java

示例7: 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());
}
 
开发者ID:NEMChina,项目名称:nem-apps,代码行数:54,代码来源:WsMonitorMultisigHandler.java

示例8: getGroupUsers

import net.sf.json.JSONObject; //导入方法依赖的package包/类
public ArrayList<User> getGroupUsers(){
	ArrayList<User> users=new ArrayList<User>();
	//用群id,vfwebqq合成一个完整的URL并且带上cookies和referer访问,将结果解析为json对象
	JSONObject result=JSONObject.fromObject(utils.get(URL.URL_GET_GROUP_INFO.replace("[var]",Long.toString(gcode)).replace("[var1]",credential.getVfWebQQ()),new HttpHeader[]{URL.URL_REFERER,credential.getCookie()}).getContent("UTF-8")).getJSONObject("result");
	//获取成员列表
	JSONArray members=result.getJSONArray("minfo");
	//获取群名片
	JSONArray cards=new JSONArray();
	//如果没有人设置群名片则此处会引发异常
	try{
	cards=result.getJSONArray("cards");
	}catch(JSONException e){
		
	}
	//获取群成员的vip信息
	JSONArray vip_info=result.getJSONArray("vipinfo");
	//遍历成员列表,填充到成员list内
	int tempIndex=0;
	for(int i=0;i<members.size();i++){
		JSONObject tempMemberInfo=JSONObject.fromObject(members.get(i));
		User tempUser=new User(tempMemberInfo.getLong("uin"));
		tempUser.setNickName(tempMemberInfo.getString("nick"));
		tempUser.setGender(tempMemberInfo.getString("gender"));
		tempUser.setVipLevel(JSONObject.fromObject(vip_info.get(i)).getInt("vip_level"));
		if(tempIndex<cards.size()&&JSONObject.fromObject(cards.get(tempIndex)).getLong("muin")==tempUser.getUID()){
		tempUser.setMarkName(JSONObject.fromObject(cards.get(tempIndex)).getString("card"));
		tempIndex++;
		}
		users.add(tempUser);
	}
	return users;
	
}
 
开发者ID:KittenDev,项目名称:WebQQAPI,代码行数:34,代码来源:Group.java


注:本文中的net.sf.json.JSONObject.getLong方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。