當前位置: 首頁>>代碼示例>>Java>>正文


Java JSONObject.isEmpty方法代碼示例

本文整理匯總了Java中com.alibaba.fastjson.JSONObject.isEmpty方法的典型用法代碼示例。如果您正苦於以下問題:Java JSONObject.isEmpty方法的具體用法?Java JSONObject.isEmpty怎麽用?Java JSONObject.isEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.alibaba.fastjson.JSONObject的用法示例。


在下文中一共展示了JSONObject.isEmpty方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isJSONObject

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/**判斷是否為JSONObject
 * @param obj instanceof String ? parseObject
 * @return
 */
public static boolean isJSONObject(Object obj) {
	if (obj instanceof JSONObject) {
		return true;
	}
	if (obj instanceof String) {
		try {
			JSONObject json = parseObject((String) obj);
			return json != null && json.isEmpty() == false;
		} catch (Exception e) {
			Log.e(TAG, "isJSONObject  catch \n" + e.getMessage());
		}
	}
	
	return false;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:JSON.java

示例2: getVersion

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
static String getVersion(int pid) throws IOException {
    String url = getConnectionUrl(pid);
    String responseText;
    try {
        responseText = HttpUtil.get(url).getResult();
    } catch (IOException e) {
        log.error("訪問{}異常",url,e);
        return "";
    }
    JSONObject responseJSON = JSONObject.parseObject(responseText);
    if (responseJSON == null || responseJSON.isEmpty()){
        return "";
    }
    JSONObject version = responseJSON.getJSONObject("version");
    if (version == null || version.isEmpty()){
        return "";
    }
    return version.getString("number");
}
 
開發者ID:DevopsJK,項目名稱:SuitAgent,代碼行數:20,代碼來源:ElasticSearchConfig.java

示例3: decodeJsonObject

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
private DataWrapper decodeJsonObject(Object o) {
    if (o instanceof Integer) {
        return new DataWrapper(DataType.INT, o);
    } else if (o instanceof Long) {
        return new DataWrapper(DataType.LONG, o);
    } else if (o instanceof Double) {
        return new DataWrapper(DataType.DOUBLE, o);
    } else if (o instanceof Boolean) {
        return new DataWrapper(DataType.BOOL, o);
    } else if (o instanceof String) {
        return new DataWrapper(DataType.UTF_STRING, o);
    } else if (o instanceof JSONObject) {
        JSONObject jso = (JSONObject) o;
        return jso.isEmpty() ? new DataWrapper(DataType.NULL, (Object) null)
                : new DataWrapper(DataType.OBJECT, this.decodeSFSObject((JSONObject) jso));
    } else if (o instanceof JSONArray) {
        return new DataWrapper(DataType.ARRAY, this.decodeSFSArray((JSONArray) ((JSONArray) o)));
    } else {
        throw new IllegalArgumentException(
                String.format("Unrecognized DataType while converting JSONObject 2 AVAObject. Object: %s, Type: %s",
                        new Object[]{o, o == null ? "null" : o.getClass()}));
    }
}
 
開發者ID:zerosoft,項目名稱:CodeBroker,代碼行數:24,代碼來源:DefaultSFSDataSerializer.java

示例4: format

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/**將Table[]:{0:{Table:{}}, 1:{Table:{}}...} 轉化為 tableList:[{}, {}]
 * @param target
 * @param response
 * @return
 */
public static JSONObject format(final JSONObject response) {
	Log.i(TAG, "format  response = \n" + JSON.toJSONString(response));
	if (response == null || response.isEmpty()) {
		Log.i(TAG, "format  response == null || response.isEmpty() >> return response;");
		return response;
	}
	JSONObject transferredObject = new JSONObject(true);

	Set<String> set = response.keySet();
	if (set != null) {
		
		Object value;
		String arrayKey;
		for (String key : set) {
			value = response.get(key);
			
			if (value instanceof JSONArray) {//轉化JSONArray內部的APIJSON Array
				transferredObject.put(getSimpleName(key), format((JSONArray) value));
			} else if (value instanceof JSONObject) {//APIJSON Array轉為常規JSONArray
				if (isArrayKey(key)) {//APIJSON Array轉為常規JSONArray
					arrayKey = key.substring(0, key.indexOf(KEY_ARRAY));
					transferredObject.put(getArrayKey(getSimpleName(arrayKey))
							, format(toArray((JSONObject) value, arrayKey)));//需要將name:alias傳至toArray
				} else {//常規JSONObject,往下一級提取
					transferredObject.put(getSimpleName(key), format((JSONObject) value));
				}
			} else {//其它Object,直接填充
				transferredObject.put(getSimpleName(key), value);
			}
		}
	}

	Log.i(TAG, "format  return transferredObject = " + JSON.toJSONString(transferredObject));
	return transferredObject;
}
 
開發者ID:TommyLemon,項目名稱:APIJSON-Android-RxJava,代碼行數:41,代碼來源:JSONResponse.java

示例5: updateStyle

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/**
 * Update styles according to the given style. Then creating a
 * command object for updating corresponding view and put the command object in the queue.
 * @param ref Reference of the dom.
 * @param style the new style. This style is only a part of the full style, and will be merged
 *              into styles
 * @see #updateAttrs(String, JSONObject)
 */
void updateStyle(String ref, JSONObject style) {
  if (mDestroy || style == null) {
    return;
  }
  WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
  WXDomObject domObject = mRegistry.get(ref);
  if (domObject == null) {
    if (instance != null) {
      instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_UPDATESTYLE);
    }
    return;
  }

  Map<String, Object> animationMap= WXDataStructureUtil.newHashMapWithExpectedSize(2);
  animationMap.put(WXDomObject.TRANSFORM, style.remove(WXDomObject.TRANSFORM));
  animationMap.put(WXDomObject.TRANSFORM_ORIGIN, style.remove(WXDomObject.TRANSFORM_ORIGIN));
  animations.add(new Pair<>(ref, animationMap));

  if(!style.isEmpty()){
    domObject.updateStyle(style);
    transformStyle(domObject, false);
    updateStyle(domObject, style);
  }
  mDirty = true;

  if (instance != null) {
    instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
  }
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:38,代碼來源:WXDomStatement.java

示例6: preHandle

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
		throws Exception {

	log.info("CommonInterceptor requestUri:{}", request.getRequestURI());
	
	HttpSession session = request.getSession();
	
	JSONObject obj = (JSONObject) session.getAttribute("cache_user");
	if (null == obj || obj.isEmpty()) {
		log.info("CommonInterceptor 用戶未登錄");
		request.getRequestDispatcher("/").forward(request, response);
		return false;
	} else {
		BigDecimal state = obj.getBigDecimal("state");
		if(!state.equals(new BigDecimal(0))) {
			log.info("用戶狀態異常,退出係統:state:{}", state);
			WebUtil.chearCache(session);
			request.getRequestDispatcher("/").forward(request, response);
			return false;
		}
		long loginTime = DateUtil.parseDate(obj.getString("loginTime")).getTime();
		long now = System.currentTimeMillis();
		if (null == cacheTime) {
			cacheTime = 10L;
		}
		log.info("cache_user:{}, cacheTime:[{} 分鍾], loginTime:{}, now:{}", obj.toJSONString(), cacheTime, DateUtil.nowStr(loginTime), DateUtil.nowStr(now));
		if (now > (loginTime + cacheTime * 1000 * 60)) {
			log.info("用戶長時間[{} 分鍾]未操作係統,退出係統:loginTime:{},now:{}", cacheTime,  DateUtil.nowStr(loginTime), DateUtil.nowStr(now));
			WebUtil.chearCache(session);
			request.getRequestDispatcher("/").forward(request, response);
			return false;
		}
		obj.put("loginTime", DateUtil.nowStr(now));
		session.setAttribute("cache_user", obj);
	}
	return true;
}
 
開發者ID:iunet,項目名稱:iunet-blog,代碼行數:39,代碼來源:CommonInterceptor.java

示例7: updateStyle

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/**
 * Update styles according to the given style. Then creating a
 * command object for updating corresponding view and put the command object in the queue.
 * @param ref Reference of the dom.
 * @param style the new style. This style is only a part of the full style, and will be merged
 *              into styles
 * @param byPesudo updateStyle by pesduo class
 * @see #updateAttrs(String, JSONObject)
 */
void updateStyle(String ref, JSONObject style, boolean byPesudo) {
  if (mDestroy || style == null) {
    return;
  }
  WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
  WXDomObject domObject = mRegistry.get(ref);
  if (domObject == null) {
    if (instance != null) {
      instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_UPDATESTYLE);
    }
    return;
  }

  Map<String, Object> animationMap= new ArrayMap<>(2);
  animationMap.put(WXDomObject.TRANSFORM, style.remove(WXDomObject.TRANSFORM));
  animationMap.put(WXDomObject.TRANSFORM_ORIGIN, style.remove(WXDomObject.TRANSFORM_ORIGIN));
  animations.add(new Pair<>(ref, animationMap));

  if(!style.isEmpty()){
    domObject.updateStyle(style, byPesudo);
    domObject.traverseTree(ApplyStyleConsumer.getInstance());
    updateStyle(domObject, style);
  }
  mDirty = true;

  if (instance != null) {
    instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
  }
}
 
開發者ID:erguotou520,項目名稱:weex-uikit,代碼行數:39,代碼來源:WXDomStatement.java

示例8: __doValidateToken

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
private boolean __doValidateToken(ISSOToken token) {
    try {
        if (SSO.get().getModuleCfg().isClientMode()) {
            Map<String, String> _params = new HashMap<String, String>();
            _params.put("token_id", token.getId());
            _params.put("uid", token.getUid());
            _params.put("remote_addr", token.getRemoteAddr());
            _params.put("sign", ParamUtils.createSignature(_params, false, SSO.get().getModuleCfg().getServiceAuthKey()));
            IHttpResponse _result = HttpClientHelper.create().post(SSO.get().getModuleCfg().getServiceBaseUrl().concat("sso/authorize"), _params, new Header[]{new BasicHeader("User-Agent", WebContext.getRequest().getHeader("User-Agent"))});
            if (_result != null && _result.getStatusCode() == 200) {
                JSONObject _resultObj = JSON.parseObject(_result.getContent());
                if (_resultObj.getIntValue("ret") == ErrorCode.SUCCESSED) {
                    // 令牌驗證通過,則進行本地Cookie存儲
                    SSO.get().getModuleCfg().getTokenAdapter().setToken(token);
                    // 嘗試從響應報文中提取並追加token屬性數據
                    JSONObject _dataObj = _resultObj.getJSONObject("data");
                    if (_dataObj != null && !_dataObj.isEmpty()) {
                        for (Map.Entry<String, Object> _attr : _dataObj.entrySet()) {
                            token.getAttributes().put(_attr.getKey(), BlurObject.bind(_attr.getValue()).toStringValue());
                        }
                    }
                    //
                    return true;
                }
            }
        } else {
            ISSOTokenStorageAdapter _storageAdapter = SSO.get().getModuleCfg().getTokenStorageAdapter();
            // 嘗試從存儲中加載原始令牌數據並進行有效性驗證
            ISSOToken _originalToken = _storageAdapter.load(token.getUid(), token.getId());
            if (_originalToken != null) {
                boolean _ipCheck = (SSO.get().getModuleCfg().isIpCheckEnabled() && !StringUtils.equals(token.getRemoteAddr(), _originalToken.getRemoteAddr()));
                if (_originalToken.timeout() || !_originalToken.verified() || _ipCheck) {
                    _storageAdapter.remove(_originalToken.getUid(), _originalToken.getId());
                } else {
                    // 嘗試加載令牌自定義屬性
                    ISSOTokenAttributeAdapter _attributeAdapter = SSO.get().getModuleCfg().getTokenAttributeAdapter();
                    if (_attributeAdapter != null) {
                        _attributeAdapter.loadAttributes(token);
                    }
                    return true;
                }
            }
        }
    } catch (Exception e) {
        _LOG.warn("An exception occurred while validate token '" + token.getId() + "' for user '" + token.getUid() + "'", RuntimeUtils.unwrapThrow(e));
    }
    return false;
}
 
開發者ID:suninformation,項目名稱:ymate-module-sso,代碼行數:49,代碼來源:SSOUserSessionHandler.java


注:本文中的com.alibaba.fastjson.JSONObject.isEmpty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。