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


Java JSONObject.getJSONObject方法代码示例

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


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

示例1: onHttpResponse

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
@Override
public void onHttpResponse(int requestCode, String resultJson, Exception e) {
	User user = null;
	try {//如果服务器返回的json一定在最外层有个data,可以用OnHttpResponseListenerImpl解析
		JSONObject jsonObject = JSON.parseObject(resultJson);
		JSONObject data = jsonObject == null ? null : jsonObject.getJSONObject("data");
		user = JSON.parseObject(data, User.class);
	} catch (Exception e1) {
		Log.e(TAG, "onHttpResponse  try { user = Json.parseObject(... >>" +
				" } catch (JSONException e1) {\n" + e1.getMessage());
	}

	if (BaseModel.isCorrect(user) == false && e != null) {
		showShortToast(R.string.get_failed);
	} else {
		setUser(user);
	}		
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:UserActivity.java

示例2: register

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
/**
 * 注册
 *
 * @param serverId 服务ID
 * @param port  服务端口号
 */
public void register(String serverId, String port) {
    this.sessionId = getRandomString();
    this.serverId = serverId;
    this.port = port;
    // 发送注册请求
    try {
        String resp = HttpUtils.sendGet(String.format("http://%s/register?id=%s&sessionId=%s&port=%s",
                this.host, serverId, this.sessionId, port));
        this.status = true;
        JSONObject obj = JSON.parseObject(resp);
        if (obj.getInteger(Constant.CODE) != 0) {
            throw new ExceptionInInitializerError("register server fail");
        }
        JSONObject data = obj.getJSONObject(Constant.DATA);
        String[] tmp = data.getString("PublicKey").split("\n");
        this.publicKey = tmp[1] + tmp[2] + tmp[3] + tmp[4];
        this.length = data.getInteger("Length");
        this.timeout = data.getInteger("Timeout");
    } catch (IOException ignored) {
    }
}
 
开发者ID:cwdtom,项目名称:hermes-java,代码行数:28,代码来源:Center.java

示例3: exports

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
public void exports(JSONObject font, Double splitAtX, Double splitAtY, Double err) {
	font.put("CFF_", null);
	JSONObject glyf = font.getJSONObject("glyf");
	for (String k : glyf.keySet()) {
		JSONObject g = glyf.getJSONObject(k);
		Contour[][] contours = g.getObject("contours", Contour[][].class);
		if (contours != null) {
			contours = c2qContours(contours, splitAtX, splitAtY, err);
		}
		g.put("contours", contours);
		g.put("stemH", null);
		g.put("stemV", null);
		g.put("hintMasks", null);
		g.put("contourMasks", null);
	}
	JSONObject maxp = font.getJSONObject("maxp");
	maxp.put("version", 1.0);
}
 
开发者ID:icaoweiwei,项目名称:otf2ttf,代码行数:19,代码来源:CTQ.java

示例4: invoke

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
@Override
public void invoke(Tuple4<String, Integer, String, Integer> inTuple4) throws InterruptedException {
    try {
        if (inTuple4 != null) {
            if (inTuple4.f2 != null && !"".equals(inTuple4.f2.trim())) {
                JSONObject data = JSONObject.parseObject(inTuple4.f2);
                JSONObject filter = data.getJSONObject("filter");
                JSONObject doc = data.getJSONObject("data");
                if (data.getString("dbName") != null) {
                    mongoManager.executeUpsert(data.getString("dbName"), data.getString("collectionName"), filter, doc);
                }
            }
        }
    } catch (Exception e) {
        logger.error("Mongo入库发生捕获的异常!{}:{}", e.getClass(), e.getMessage());
        for (StackTraceElement element : e.getStackTrace()) {
            logger.error("\tat {}", element.toString());
        }
    }
}
 
开发者ID:breakEval13,项目名称:rocketmq-flink-plugin,代码行数:21,代码来源:MongoSink.java

示例5: globalControlEmailJsonVo2HTML

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
public static String globalControlEmailJsonVo2HTML(JSONObject json) {
        JSONObject payload = json.getJSONObject("payload");
        JSONObject beforeMap = payload.getJSONObject("before");
        JSONObject afterMap = payload.getJSONObject("after");

        final String HTML_LINE_SEPARATOR = "<br/>";
//        final String HTML_INDENT = "&nbsp;&nbsp;";
        StringBuilder output = new StringBuilder();
        output.append("您好,数据库表结构发生变更!!!"+HTML_LINE_SEPARATOR);
        output.append("时间:" + json.getString("timestamp") + HTML_LINE_SEPARATOR);
        output.append("表名:" + StringUtils.join(new Object[] {payload.get("datasource"),payload.get("schema"),payload.get("table")}, ".") + HTML_LINE_SEPARATOR);
        output.append("新版本号:" + payload.getString("version") + HTML_LINE_SEPARATOR);
        output.append("变更前后对比:" + HTML_LINE_SEPARATOR);
        output.append(compareListHTML(beforeMap.getJSONArray("columns"),afterMap.getJSONArray("columns")));
        return output.toString();
    }
 
开发者ID:BriData,项目名称:DBus,代码行数:17,代码来源:HTMLUtil.java

示例6: parseEsResponse

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
/**
 * 解析log
 * @param response
 * @return
 */
private Map<String, Object> parseEsResponse(String response) {
    Map<String, Object> result = new HashMap<String, Object>();
    if (null == response) {
        // 错误
        return null;
    } else {
        JSONObject json = JSON.parseObject(response);
        List<NoneDupeLogDto> logs = new ArrayList<NoneDupeLogDto>();
        JSONObject hits = json.getJSONObject("hits");
        Iterator<Object> iterator = hits.getJSONArray("hits").iterator();
        while (iterator.hasNext()) {
            LogDto logDto = JSON.parseObject(((JSONObject) iterator.next()).getString("_source"), LogDto.class);
            logs.add(new NoneDupeLogDto(logDto.getNanoTime(), logDto.toString()));
        }
        result.put("logs", logs);
        result.put("total", hits.getInteger("total"));
        result.put("current", logs.size());
        return result;
    }
}
 
开发者ID:JThink,项目名称:SkyEye,代码行数:26,代码来源:LogQueryService.java

示例7: sendAckInfoToCtrlTopic

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
private static void sendAckInfoToCtrlTopic(String dataSourceInfo, String completedTime, String pullStatus) {
    try {
        // 在源dataSourceInfo的基础上,更新全量拉取相关信息。然后发回src topic
        JSONObject jsonObj = JSONObject.parseObject(dataSourceInfo);
        jsonObj.put(DataPullConstants.FullPullInterfaceJson.FROM_KEY, DataPullConstants.FullPullInterfaceJson.FROM_VALUE);
        jsonObj.put(DataPullConstants.FullPullInterfaceJson.TYPE_KEY, DataPullConstants.FullPullInterfaceJson.TYPE_VALUE);
        // notifyFullPullRequestor
        JSONObject payloadObj = jsonObj.getJSONObject(DataPullConstants.FullPullInterfaceJson.PAYLOAD_KEY);
        // 完成时间
        payloadObj.put(DataPullConstants.FullPullInterfaceJson.COMPLETE_TIME_KEY, completedTime);
        // 拉取是否成功标志位
        payloadObj.put(DataPullConstants.FullPullInterfaceJson.DATA_STATUS_KEY, pullStatus);
        jsonObj.put(DataPullConstants.FullPullInterfaceJson.PAYLOAD_KEY, payloadObj);
        String ctrlTopic = getFullPullProperties(Constants.ZkTopoConfForFullPull.COMMON_CONFIG, true)
            .getProperty(Constants.ZkTopoConfForFullPull.FULL_PULL_SRC_TOPIC);
        Producer producer = DbusHelper
                .getProducer(getFullPullProperties(Constants.ZkTopoConfForFullPull.BYTE_PRODUCER_CONFIG, true));
        ProducerRecord record = new ProducerRecord<>(ctrlTopic, DataPullConstants.FullPullInterfaceJson.TYPE_VALUE, jsonObj.toString().getBytes());
        Future<RecordMetadata> future = producer.send(record);
        RecordMetadata meta = future.get();
    }
    catch (Exception e) {
        Log.error("Error occurred when report full data pulling status.", e);
        throw new RuntimeException(e);
    }
}
 
开发者ID:BriData,项目名称:DBus,代码行数:27,代码来源:FullPullHelper.java

示例8: addSystemLog

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
/**添加系统日志*/
private void addSystemLog(HttpServletRequest request,ReturnUtil returnUtil, JSONObject handlerJson, String explain) {
	JSONObject log = new JSONObject();
	JSONObject member = StorageUtil.init(request.getSession()).getLoginMemberInfoJson();
	if(member!=null){
		log.put("memberId", member.getLong("id"));
	}
	String ip = DataUtil.getIpAddress(request);
	if(!DataUtil.internalIp(ip)){
		JSONObject ipJson = new JSONObject();
		ipJson.put("ip", ip);
		ReturnUtil ip_return = myBaseService.get(null,ipJson, "systemMapper.getIpLibrary");
		if(ip_return.getCode()==ReturnUtil.SUCCESS_CODE && ip_return.getResult_data()!=null){
			log.put("ip_library_id", ip_return.gDataMap().get("id"));
		}else{
			JSONObject tbaoIpLibrary = DataUtil.getAddressByIP(ip);
			ipJson = tbaoIpLibrary.getJSONObject("data");
			ReturnUtil ipLibraryReturn = myBaseService.add(null,ipJson, "systemMapper.addIpLibrary", true);
			if(ipLibraryReturn.getCode()==ReturnUtil.SUCCESS_CODE){
				log.put("ip_library_id", ipLibraryReturn.getExtend_info());
			}
		}
	}else{
		log.put("ip_library_id", -1);
	}
	String method = handlerJson.getString("beanType")+"."+handlerJson.getJSONObject("method").getString("name");
	log.put("handler", method);
	log.put("explain", explain);
	log.put("have_authority", returnUtil.getCode()==ReturnUtil.SUCCESS_CODE);
	log.put("parameter", DataUtil.requestToJson(request).toJSONString());
	request.setAttribute(Statics.SYSTEM_LOG_ID, log.toJSONString());
}
 
开发者ID:zhiqiang94,项目名称:BasicsProject,代码行数:33,代码来源:AuthorityAnnotationInterceptor.java

示例9: getUserInfo

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
public static User getUserInfo (int uid, JSONObject object, boolean loadFull) throws APIException {
    if (mCachedUsers.containsKey(uid)) {
        // TODO: 这里会缓存 简短的用户信息 ,当获取完整信息时也会取出缓存。
        return mCachedUsers.get(uid);
    }
    try {
        JSONObject data = object.getJSONObject("data");
        User user = new User();
        user.setId(uid);
        JSONObject attributes;
        if (loadFull) {
            attributes = data.getJSONObject("attributes");
        } else {
            attributes = object.getJSONObject("attributes");
        }
        user.setUsername(attributes.getString("username"));
        user.setAvatarUrl(attributes.getString("avatarUrl"));
        if (loadFull) {
            user.setBio(attributes.getString("bio"));
            user.setJoinTime(attributes.getString("joinTime"));
            user.setDiscussionsCount(attributes.getInteger("discussionsCount"));
            user.setCommentsCount(attributes.getInteger("commentsCount"));
            user.setCanEdit(attributes.getBoolean("canEdit"));
            user.setCanDelete(attributes.getBoolean("canDelete"));
            user.setCanSuspend(attributes.getBoolean("canSuspend"));
            user.setVingleShareSocial(attributes.getString("vingle.share.social"));
            //TODO:Group
        }
        mCachedUsers.put(uid, user);
        return user;
    } catch (JSONException e) {
        throw new APIException(e);
    }
}
 
开发者ID:ProjectFishpond,项目名称:TPondof,代码行数:35,代码来源:UserItemManager.java

示例10: getTag

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
public static Tag getTag (int id, JSONObject object) throws APIException {
    if (DEBUG) Log.i(TAG, "-> getTag");
    try {
        if (mCachedTags.containsKey(id)) {
            return mCachedTags.get(id);
        }
        Tag tag = new Tag();
        tag.setId(object.getInteger("id"));
        JSONObject attributes = object.getJSONObject("attributes");
        tag.setName(attributes.getString("name"));
        tag.setDescription(attributes.getString("description"));
        tag.setSlug(attributes.getString("slug"));
        tag.setColor(Color.parseColor(attributes.getString("color")));
        tag.setBackgroundUrl(attributes.getString("backgroundUrl"));
        tag.setBackgroundMode(attributes.getString("backgroundMode"));
        tag.setIconUrl(attributes.getString("iconUrl"));
        tag.setDiscussionsCount(attributes.getInteger("discussionsCount"));
        //tag.setPosition(attributes.getInteger("position"));
        tag.setDefaultSort(attributes.getString("defaultSort"));
        tag.setChild(attributes.getBoolean("isChild"));
        tag.setHidden(attributes.getBoolean("isHidden"));
        tag.setLastTime(attributes.getString("lastTime"));
        tag.setCanStartDiscussion(attributes.getBoolean("canStartDiscussion"));
        tag.setCanAddToDiscussion(attributes.getBoolean("canAddToDiscussion"));
        mCachedTags.put(id, tag);
        return tag;
    } catch (JSONException e) {
        throw new APIException(e);
    }
}
 
开发者ID:ProjectFishpond,项目名称:TPondof,代码行数:31,代码来源:TagManager.java

示例11: test_for_alipay

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
public void test_for_alipay() throws Exception {
    File file = new File("/Users/wenshao/Downloads/x.txt");
    String text = FileUtils.readFileToString(file);
    JSONObject root = JSON.parseObject(text);

    JSONObject resultObj = root.getJSONObject("resultObj");
    assertNotNull(resultObj);

    JSONArray conditionGroupItemList = resultObj.getJSONArray("conditionGroupItemList");
    assertNotNull(conditionGroupItemList);

    JSONObject conditionGroup = conditionGroupItemList.getJSONObject(0).getJSONObject("conditionGroup");
    assertNotNull(conditionGroup);

    JSONArray recordList = conditionGroup.getJSONArray("recordList");
    assertNotNull(recordList);

    JSONArray conditionItemList = recordList.getJSONObject(0).getJSONArray("conditionItemList");
    assertNotNull(conditionItemList);

    JSONObject condition = conditionItemList.getJSONObject(18).getJSONObject("condition");
    assertNotNull(condition);

    JSONArray conditionConstraint = condition.getJSONArray("conditionConstraint");
    assertNotNull(conditionConstraint);

    JSONObject constraintOptionalRecordMap = conditionConstraint.getJSONObject(0).getJSONObject("constraintOptionalRecordMap");
    assertNotNull(constraintOptionalRecordMap);

    System.out.println(constraintOptionalRecordMap);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:32,代码来源:Alipay1206.java

示例12: parseURLSWithJSONObject

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
private static List<String> parseURLSWithJSONObject(final JSONObject object) {

        final JSONObject range = object.getJSONObject("first_range");
        final JSONArray journals = object.getJSONArray("journals");
        final String article_type = object.getString("article_type");
        final String order = object.getString("order");

        return journals.stream()
                .map(journal -> concatUrl(range, journal, article_type, order))
                .collect(Collectors.toList());
    }
 
开发者ID:HongChutang,项目名称:NTPaprEng,代码行数:12,代码来源:Helper.java

示例13: getNodeNameOrId

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
private static String getNodeNameOrId(int pid,int type) throws IOException {
    String selfNodeId = "";
    String selfNodeName = "";
    String netWorkHost = getNetworkHost(pid);
    int port = getHttpPort(pid);
    String url = getConnectionUrl(pid) + "/_nodes";
    String responseText;
    try {
        responseText = HttpUtil.get(url).getResult();
    } catch (IOException e) {
        log.error("访问{}异常",url,e);
        return "";
    }
    JSONObject responseJSON = JSONObject.parseObject(responseText);
    JSONObject nodes = responseJSON.getJSONObject("nodes");
    if(nodes != null){
        for (Map.Entry<String, Object> entry : nodes.entrySet()) {
            String nodeId = entry.getKey();
            JSONObject nodeInfo = (JSONObject) entry.getValue();
            String nodeName = nodeInfo.getString("name");
            String httpAddress = nodeInfo.getString("http_address");
            if (StringUtils.isEmpty(httpAddress)) {
                selfNodeId = nodeId;
                selfNodeName = nodeName;
            }else {
                if("127.0.0.1".equals(netWorkHost) || "localhost".equals(netWorkHost)){
                    if(httpAddress.contains("127.0.0.1:" + port) || httpAddress.contains("localhost:" + port)){
                        selfNodeId = nodeId;
                        selfNodeName = nodeName;
                    }
                }else{
                    if(httpAddress.contains(netWorkHost + ":" + port)){
                        selfNodeId = nodeId;
                        selfNodeName = nodeName;
                    }
                }
            }
        }
    }else{
        log.error("elasticSearch json结果解析失败:{}",responseText);
    }
    switch (type){
        case 1:
            return selfNodeId;
        case 2:
            return selfNodeName;
        default:
            return "";
    }
}
 
开发者ID:DevopsJK,项目名称:SuitAgent,代码行数:51,代码来源:ElasticSearchConfig.java

示例14: test_for_issue

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
public void test_for_issue() throws Exception {
    JSONObject json = new JSONObject();
    json.put("robj", "{abc: 123}");
    JSONObject robj = json.getJSONObject("robj");
    assertEquals(123, robj.get("abc"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:Issue780.java

示例15: pushNative

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
@JSMethod
public void pushNative(String encodeParam, JSCallback callback) {
    if (TextUtils.isEmpty(encodeParam)) {
        return;
    }
    try {
        JSONObject options = JSON.parseObject(encodeParam);
        String url = "";
        UWXTheme.NavBar navBar = null;
        JSONObject param = null;
        if (options.containsKey(UWXBundleInfo.KEY_URL)) {
            url = options.getString(UWXBundleInfo.KEY_URL);
        }
        if (options.containsKey(UWXBundleInfo.KEY_NAV_BAR)) {
            String _navBar = options.getString(UWXBundleInfo.KEY_NAV_BAR);
            if (!TextUtils.isEmpty(_navBar)) {
                navBar = JSON.parseObject(_navBar, UWXTheme.NavBar.class);
            }
        }
        if (options.containsKey(UWXBundleInfo.KEY_PARAM)) {
            param = options.getJSONObject(UWXBundleInfo.KEY_PARAM);
        }
        UWLog.v("params=" + encodeParam);
        if (!TextUtils.isEmpty(url)) {
            UWXNavigatorAdapter navigatorAdapter = UWXSDKManager.getInstance().getNavigatorAdapter();
            if (navigatorAdapter != null) {
                navigatorAdapter.pushNative((Activity) mWXSDKInstance.getContext(),url ,param);
                if (callback != null) {
                    callback.invoke(MSG_SUCCESS);
                }
            }
        } else {
            callback.invoke(MSG_FAILED);
        }
    } catch (Exception e) {
        WXLogUtils.eTag(TAG, e);
        if (callback != null) {
            callback.invoke(MSG_FAILED);
        }
    }
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:42,代码来源:UWXNavigatorModule.java


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