當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。