当前位置: 首页>>代码示例>>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;未经允许,请勿转载。