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


Java JSONObject.getString方法代码示例

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


在下文中一共展示了JSONObject.getString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
@Test
public void main() throws IOException {
    File a = FileUtils.getFile("D:/a.txt");
    String str = FileUtils.readFileToString(a,"utf-8");
    JSONObject json = JSON.parseObject(str);
    JSONArray arry = JSONArray.parseArray(json.get("delegates").toString());
    for(int i = 0;i<arry.size();i++){
        JSONObject obj= (JSONObject) arry.get(i);
        String username =  obj.getString("username");
        String productivity =  obj.getString("productivity");
        String producedblocks = obj.getString("producedblocks");
        String balance = obj.getString("balance");
        String approval = obj.getString("approval");
        System.out.println(username +"||" + productivity +"||" + producedblocks + "||" + balance + "||" + approval);
    }
}
 
开发者ID:AschPlatform,项目名称:asch-java,代码行数:17,代码来源:AccountServiceTest.java

示例2: getWxUserinfo

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
/** 获取微信用户信息 */
public static final ThirdPartyUser getWxUserinfo(String token, String openid) throws Exception {
	ThirdPartyUser user = new ThirdPartyUser();
	String url = Resources.THIRDPARTY.getString("getUserInfoURL_wx");
	url = url + "?access_token=" + token + "&openid=" + openid;
	String res = HttpUtil.httpClientPost(url);
	JSONObject json = JSONObject.parseObject(res);
	if (json.getString("errcode") == null) {
		user.setUserName(json.getString("nickname"));
		String img = json.getString("headimgurl");
		if (img != null && !"".equals(img)) {
			user.setAvatarUrl(img);
		}
		String sex = json.getString("sex");
		if ("0".equals(sex)) {
			user.setGender("0");
		} else {
			user.setGender("1");
		}
	} else {
		throw new IllegalArgumentException(json.getString("errmsg"));
	}
	return user;
}
 
开发者ID:guokezheng,项目名称:automat,代码行数:25,代码来源:ThirdPartyLoginHelper.java

示例3: convert

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
@Override
public ArrayList<MultipleItemEntity> convert() {
    final ArrayList<MultipleItemEntity> dataList = new ArrayList<>();
    final JSONArray dataArray = JSON.parseObject(getJsonData())
            .getJSONObject("data").getJSONArray("list");
    final int size = dataArray.size();
    for (int i = 0; i < size; i++) {
        final JSONObject data = dataArray.getJSONObject(i);
        final int id = data.getInteger("id");
        final String name = data.getString("name");
        final MultipleItemEntity entity = MultipleItemEntity.builder()
                .setField(MultipleFields.ITEM_TYPE, ItemType.VERTICAL_MENU_LIST)
                .setField(MultipleFields.ID, id)
                .setField(MultipleFields.TEXT, name)
                .setField(MultipleFields.TAG, false).build();
        dataList.add(entity);
        //设置选中第一个
        dataList.get(0).setField(MultipleFields.TAG, true);

    }

    return dataList;
}
 
开发者ID:remerber,项目名称:FastEc,代码行数:24,代码来源:VerticalListDataConverter.java

示例4: getMasterID

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
/**
 * 获得master结点 server id
 *
 * @param workerType
 * @return
 */
public static String getMasterID(ZkClient zkClient,String workerType){
    String zkPath = "/"+ Constants.SAF_WORKER_ROOT+"/"+workerType+"/"+Constants.SAF_WORKER_SERVER;
    byte[] value = zkClient.readData(zkPath,true);
    if( value == null || value[0] == 0){
        logger.warn("{} master is null", zkPath);
        return null;
    }
    String master = new String(value);
    if ( StringUtils.isEmpty(master)){
        logger.warn("{} master is null", zkPath);
        return null;
    }
    JSONObject masterJSON = null;
    try {
        masterJSON = JSONObject.parseObject(master);
    } catch (JSONException e) {
        logger.error("#{}# error master server id for [{}} ",master,workerType,e);
        return null;
    }
    return StringUtils.isNotEmpty(masterJSON.getString(FIXEDMASTER)) ? masterJSON.getString(FIXEDMASTER):masterJSON.getString(MASTERID);
}
 
开发者ID:tiglabs,项目名称:jsf-core,代码行数:28,代码来源:WorkerUtil.java

示例5: parseReceive

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
protected DataTransferObject parseReceive(String jsonResult) {
    DataTransferObject dto = new DataTransferObject();
    //判断为空
    if (Check.NuNStr(jsonResult)) {
        dto.setErrCode(DataTransferObject.ERROR);
        dto.putValue("data", "未取得返回数据");
        return dto;
    }
    //转成map
    JSONObject jsonObject = JSON.parseObject(jsonResult);
    String code = jsonObject.getString("response_code");
    //如果服务器返回异常
    if (!"0".equals(code)) {
        dto.setErrCode(DataTransferObject.ERROR);
        dto.putValue("data", jsonObject.get("error_info"));
        return dto;
    }
    //返回正确,将数据取回到dto
    String uplinks = jsonObject.getString("uplinks");
    List<SmsReceiveMessage> receiveMessages = JSON.parseArray(uplinks, SmsReceiveMessage.class);
    dto.putValue("data", receiveMessages);
    return dto;
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:24,代码来源:AbstractHttpSmsReceiver.java

示例6: doProcess

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
@Override
public final QCloudMsgResponse doProcess(String jsonBody,Map<String,Object> urlParams,String key) {
	JSONObject jsonObject = JSON.parseObject(jsonBody);
	String sign = jsonObject.getString("sign");
	long t = jsonObject.getLongValue("t");
	if (!isValid(t, key, sign)) {
		return onInvalidMsg(jsonBody);
	}
	int eventType = jsonObject.getIntValue("event_type");
	switch (eventType) {
	case LiveMsgEventType.CUT_STREAM:
		return onCutStream(JSON.parseObject(jsonBody, LiveMsgStreamEventDO.class));
	case LiveMsgEventType.PUSH_STREAM:
		return onPushStream(JSON.parseObject(jsonBody, LiveMsgStreamEventDO.class));
	case LiveMsgEventType.RECORD_AV_CREATED:
		return onAvRecordCreated(JSON.parseObject(jsonBody, LiveMsgAvRecordCreatedDO.class));
	case LiveMsgEventType.SCREENSHOT_CREATED:
		return onScreenshotCreated(JSON.parseObject(jsonBody, LiveMsgScreenshotCreatedDO.class));
	default:
		break;
	}
	return LiveMsgResponse.FAILED;
}
 
开发者ID:51wakeup,项目名称:wakeup-qcloud-sdk,代码行数:24,代码来源:AbstractLiveMsgListener.java

示例7: createOrUpdateViewMeta

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
/**
 * update the meta if the view updated
 */
private void createOrUpdateViewMeta(ChildData childData, boolean isReplace) throws Exception {
    String path = childData.getPath();
    String[] paths = path.split("/");
    String jsonValue = new String(childData.getData(), StandardCharsets.UTF_8);
    JSONObject obj = (JSONObject) JSONObject.parse(jsonValue);

    //if the view is create or replace by this server it self
    String serverId = obj.getString(SERVER_ID);
    if (serverId.equals(ZkConfig.getInstance().getValue(ZkParamCfg.ZK_CFG_MYID))) {
        return;
    }
    String createSql = obj.getString(CREATE_SQL);
    String schema = paths[paths.length - 1].split(SCHEMA_VIEW_SPLIT)[0];

    ViewMeta vm = new ViewMeta(createSql, schema, DbleServer.getInstance().getTmManager());
    vm.initAndSet(isReplace);

}
 
开发者ID:actiontech,项目名称:dble,代码行数:22,代码来源:ViewChildListener.java

示例8: sinaCallback

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
@RequestMapping("callback/sina")
public String sinaCallback(HttpServletRequest request, ModelMap modelMap) {
	String host = request.getHeader("host");
	try {
		String code = request.getParameter("code");
		if (StringUtils.isNotBlank(code)) {// 如果不为空
			// 获取token和uid
			JSONObject json = ThirdPartyLoginHelper.getSinaTokenAndUid(code, host);
			String uid = json.getString("uid");
			if (StringUtils.isNotBlank(uid)) {// 如果uid存在
				// 获取第三方用户信息存放到session中
				ThirdPartyUser thirdUser = ThirdPartyLoginHelper.getSinaUserinfo(json.getString("access_token"),
						uid);
				thirdUser.setProvider("SINA");
				thirdPartyLogin(request, thirdUser);
				// 跳转到登录成功界面
				modelMap.put("retUrl", Resources.THIRDPARTY.getString("third_login_success"));
			} else {// 如果未获取到OpenID
					// 跳转到登录成功界面
				modelMap.put("retUrl", "-1");
			}
		} else {// 如果没有返回令牌,则直接返回到登录页面
				// 跳转到登录成功界面
			modelMap.put("retUrl", "-1");
		}
	} catch (Exception e) {
		// 跳转到登录失败界面
		modelMap.put("retUrl", "-1");
		e.printStackTrace();
	}

	return "/sns/redirect";
}
 
开发者ID:babymm,项目名称:mumu,代码行数:34,代码来源:ThirdPartyLoginController.java

示例9: parse

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
/**
 * 从JsonObject中解析出SlaveNode
 * @param object
 * @return
 */
public static SlaveNode parse(JSONObject object){
    if(object==null){
        return null;
    }
    String host = object.getString("host");
    int port = object.getIntValue("port");
    String id = object.getString("id");
    return new SlaveNode(id,host,port);
}
 
开发者ID:all4you,项目名称:redant,代码行数:15,代码来源:SlaveNode.java

示例10: initToken

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
private static void initToken() {
	if (tokenTime == null || tokenExpire == null || System.currentTimeMillis() - tokenTime >= tokenExpire) {
		String uriString = "https://api.weixin.qq.com/cgi-bin/token?grant_type=" + grantType + "&appid="
				+ PropertiesUtil.getString("WX_PUBLIC_APPID") + "&secret="
				+ PropertiesUtil.getString("WX_PUBLIC_SECRET");
		try {
			URL url = new URL(uriString);
			HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection();
			InputStreamReader inputStreamReader = new InputStreamReader(httpsURLConnection.getInputStream());
			int responseInt = inputStreamReader.read();
			StringBuffer stringBuffer = new StringBuffer();
			while (responseInt != -1) {
				stringBuffer.append((char) responseInt);
				responseInt = inputStreamReader.read();
			}
			String tokenString = stringBuffer.toString();
			JSONObject jsonObject = JSON.parseObject(tokenString);
			if (jsonObject.containsKey("access_token")) {
				tokenTime = System.currentTimeMillis();
				token = jsonObject.getString("access_token");
				tokenExpire = jsonObject.getLong("expires_in");
			} else {
				// TODO 验证错误
				System.out.println(jsonObject.get("errcode"));
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}
 
开发者ID:youngMen1,项目名称:JAVA-,代码行数:31,代码来源:WeiXinUtils.java

示例11: buildDottedNameSpace

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
public String buildDottedNameSpace(String dataSourceInfo){
    String dbName = (String)(this.properties.get(DBConfiguration.DataSourceInfo.DB_NAME));
    JSONObject ds=JSONObject.parseObject(dataSourceInfo);
    JSONObject payload = ds.getJSONObject(DataPullConstants.FullPullInterfaceJson.PAYLOAD_KEY);
    //      String dbSchema = (String)(this.properties.get(DBConfiguration.DataSourceInfo.DB_SCHEMA));
    //      String tableName = (String)(this.properties.get(DBConfiguration.DataSourceInfo.TABLE_NAME));
    String dbSchema = payload.getString(DataPullConstants.FULL_DATA_PULL_REQ_PAYLOAD_SCHEMA_NAME);
    String tableName = payload.getString(DataPullConstants.FULL_DATA_PULL_REQ_PAYLOAD_TABLE_NAME);
    String version = payload.getString(DataPullConstants.FullPullInterfaceJson.VERSION_KEY);
    return String.format("%s.%s.%s.%s", dbName, dbSchema, tableName, version);
  
}
 
开发者ID:BriData,项目名称:DBus,代码行数:13,代码来源:DBConfiguration.java

示例12: parseUploadResult

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
private void parseUploadResult(String result) {
	JSONObject jsonObject = JSONObject.parseObject(result);
	if (jsonObject.containsKey(PARAM_MEDIA_ID)) {
		this.mediaId = jsonObject.getString(PARAM_MEDIA_ID);
		this.createdTimestamp = jsonObject.getString(PARAM_CREATE_TIME);
	} else {
		this.mediaId = null;
		this.createdTimestamp = null;
	}
}
 
开发者ID:funtl,项目名称:framework,代码行数:11,代码来源:MediaFile.java

示例13: initToken

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
private static void initToken() {
	if (tokenTime == null || tokenExpire == null || System.currentTimeMillis() - tokenTime >= tokenExpire
			|| token == null) {
		String uriString = "https://qyapi.weixin.qq.com/cgi-bin/gettoken";
		StringBuffer sb = new StringBuffer();
		sb.append(uriString);
		sb.append("?corpid=").append(PropertiesUtil.getString("WX_QY_CORPID"));
		sb.append("&corpsecret=").append(PropertiesUtil.getString("WX_QY_CORPSECRET"));

		try {
			System.out.println(sb);
			URL url = new URL(sb.toString());
			HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection();
			InputStreamReader inputStreamReader = new InputStreamReader(httpsURLConnection.getInputStream());
			int responseInt = inputStreamReader.read();
			StringBuffer stringBuffer = new StringBuffer();
			while (responseInt != -1) {
				stringBuffer.append((char) responseInt);
				responseInt = inputStreamReader.read();
			}
			String tokenString = stringBuffer.toString();
			System.out.println(stringBuffer);
			JSONObject jsonObject = JSON.parseObject(tokenString);
			if (jsonObject.containsKey("access_token")) {
				tokenTime = System.currentTimeMillis();
				token = jsonObject.getString("access_token");
				tokenExpire = jsonObject.getLong("expires_in");
			} else {
				// TODO 验证错误
				System.out.println(jsonObject.get("errcode"));
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}
 
开发者ID:guokezheng,项目名称:automat,代码行数:37,代码来源:WeiXinCompanyUtils.java

示例14: AccessToken

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
public AccessToken(String res) throws WeiboException{
	super();
	JSONObject json =JSONObject.parseObject(res);
	accessToken = json.getString("access_token");
	expireIn = json.getString("expires_in");
	refreshToken = json.getString("refresh_token");
	uid = json.getString("uid");
}
 
开发者ID:liaojiacan,项目名称:zhkuas_ssm_maven,代码行数:9,代码来源:AccessToken.java

示例15: push

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
@JSMethod(uiThread = true)
public void push(String param, JSCallback callback) {

    if (!TextUtils.isEmpty(param)) {
        if (WXSDKEngine.getActivityNavBarSetter() != null) {
            if (WXSDKEngine.getActivityNavBarSetter().push(param)) {
                callback.invoke(MSG_SUCCESS);
                return;
            }
        }

        try {
            JSONObject jsonObject = JSON.parseObject(param);
            String url = jsonObject.getString(URL);
            if (!TextUtils.isEmpty(url)) {
                Uri rawUri = Uri.parse(url);
                String scheme = rawUri.getScheme();
                Uri.Builder builder = rawUri.buildUpon();
                if (TextUtils.isEmpty(scheme)) {
                    builder.scheme(Constants.Scheme.HTTP);
                }
                Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
                intent.addCategory(WEEX);
                intent.putExtra(INSTANCE_ID, mWXSDKInstance.getInstanceId());
                mWXSDKInstance.getContext().startActivity(intent);
                callback.invoke(MSG_SUCCESS);
            }
        } catch (Exception e) {
            WXLogUtils.eTag(TAG, e);
            callback.invoke(MSG_FAILED);
        }
    }

    callback.invoke(MSG_FAILED);
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:36,代码来源:WXNavigatorModule.java


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