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


Java JSONObject.entrySet方法代碼示例

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


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

示例1: GameService

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
public GameService(ApplicationContext context) {
    String[] beans = context.getBeanNamesForAnnotation(Game.class);
    Map<String, GameInfo> info = new LinkedHashMap<>();
    for (String bean : beans) {
        Class<?> aClass;
        try {
            aClass = Class.forName(context.getBean(bean).getClass().getName().split("\\$")[0]);
        } catch (ClassNotFoundException e) {
            throw new IllegalStateException(e);
        }
        Game annotation = aClass.getAnnotation(Game.class);
        String name = annotation.gameName();
        String value = annotation.value();
        JSONObject attrs = JSON.parseObject(annotation.attrs());
        GameInfo gameInfo = new GameInfo().setName(name).setIdentify(value);
        for (Map.Entry<String, Object> entry : attrs.entrySet()) {
            gameInfo.putAttr(entry.getKey(), entry.getValue());
        }
        info.put(value, gameInfo);
        LOGGER.info("[GameService]注冊遊戲 [{}]", name);
    }
    this.info = Collections.unmodifiableMap(info);
}
 
開發者ID:csdbianhua,項目名稱:telemarket-skittle-alley,代碼行數:24,代碼來源:GameService.java

示例2: parseList

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
public static List<TagResult> parseList(String json) {
    JSONArray array = JSON.parseArray(json);
    List<TagResult> arrayList = new ArrayList<TagResult>(array.size());

    Iterator<Object> iterator = array.iterator();
    while (iterator.hasNext()) {
        JSONObject object = (JSONObject) iterator.next();
        Set<Entry<String, Object>> entrySet = object.entrySet();
        for (Entry<String, Object> entry : entrySet) {
            String key = entry.getKey();
            String value = entry.getValue().toString();
            TagResult tagResult = new TagResult(key, value);
            arrayList.add(tagResult);
            break;
        }
    }

    return arrayList;
}
 
開發者ID:aliyun,項目名稱:HiTSDB-Client,代碼行數:20,代碼來源:TagResult.java

示例3: DefaultLogFilterAndRule

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/**
 * 構造默認的日誌規則
 * 
 * @param filterregex
 *            日誌過濾規則的正則表達式
 * @param separator
 *            日誌字段分隔符
 * @param fields
 *            日誌字段名以及對應在的列號
 * @param fieldNumber
 *            指定對應的列號值為時間戳
 * @param version
 *            規則當前的版本
 */
public DefaultLogFilterAndRule(String filterregex, String separator, JSONObject fields, int fieldNumber,
        int version) {

    this.filterPattern = Pattern.compile(filterregex);

    this.separator = Splitter.on(separator).trimResults();
    this.SpecifiedFields = new Integer[fields.size()];
    this.fieldsName = new String[fields.size()];
    int i = 0;
    for (Entry<String, Object> entry : fields.entrySet()) {
        fieldsName[i] = entry.getKey();
        SpecifiedFields[i++] = (Integer) entry.getValue();
    }
    this.timeStampField = fieldNumber;

    this.version = version;

    @SuppressWarnings("rawtypes")
    List<Map> mainlogs = Lists.newLinkedList();

    setMainlogs(mainlogs);
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:37,代碼來源:DefaultLogFilterAndRule.java

示例4: mergeJSONObject

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
private static void mergeJSONObject(JSONObject target, JSONObject from, ArrayMergeStrategy arrayMergeStrategy){
    for (Map.Entry<String, Object> field : from.entrySet()) {
        if (target.containsKey(field.getKey())) {
            Object targetFieldValue = target.get(field.getKey());
            Object fromFieldValue = field.getValue();
            if ((targetFieldValue instanceof JSONObject) && (fromFieldValue instanceof JSONObject)) {
                // 都是 JSON 對象,進行深度合並;
                mergeJSONObject((JSONObject) targetFieldValue, (JSONObject) fromFieldValue, arrayMergeStrategy);
            } else if ((targetFieldValue instanceof JSONArray) && (fromFieldValue instanceof JSONArray)) {
                // 都是 JSON 數組,進行數組合並;
                mergeJSONArray((JSONArray) targetFieldValue, (JSONArray) fromFieldValue, arrayMergeStrategy);
            } else {
                // 類型不同,直接替換;
                target.put(field.getKey(), field.getValue());
            }
        } else {
            target.put(field.getKey(), field.getValue());
        }
    }
}
 
開發者ID:bubicn,項目名稱:bubichain-sdk-java,代碼行數:21,代碼來源:JSONBean.java

示例5: addHeadersToRequest

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
private static void addHeadersToRequest(URLConnection connection, JSONObject headers) {
    for (Map.Entry<String, Object> entry : headers.entrySet()) {
        String headerKey = entry.getKey().replaceAll("\\s+", "").replaceAll("[^\\x20-\\x7E]+", "");
        String headerValue = entry.getValue().toString();

        connection.setRequestProperty(headerKey, headerValue);
    }
}
 
開發者ID:natjs,項目名稱:nat-network-transfer,代碼行數:9,代碼來源:TransferModule.java

示例6: test_0

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
public void test_0() throws Exception {
    String json = "{\"schema\":{\"$ref\":{\"@title\":\"類目ID\",\"@type\":\"string\"},\"$\":{\"@\":\"類目名稱\",\"type\":\"string\"},\"cat_desc\":{\"title\":\"類目描述\",\"type\":\"string\"}}}";
    JSONObject errorJson = JSON.parseObject(json, Feature.DisableSpecialKeyDetect);
    JSONObject schema = errorJson.getJSONObject("schema");
    Set<Map.Entry<String, Object>> es2 = schema.entrySet();
    for (Map.Entry<String, Object> entry : es2) {
        System.out.println(entry.getKey() + "_" + entry.getValue());
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:DisableSpecialKeyDetectTest.java

示例7: toNameValues

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
public static NameValues toNameValues(JSONObject jsonObject)
{
    NameValues nameValues = new NameValues(jsonObject.size());
    for (Map.Entry<String, Object> entry : jsonObject.entrySet())
    {
        nameValues.append(entry.getKey(), entry.getValue());
    }
    return nameValues;
}
 
開發者ID:gzxishan,項目名稱:OftenPorter,代碼行數:10,代碼來源:DataUtil.java

示例8: putAll

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/**
 * Put the map info in the JSONObject to the container.
 * This method check for null value in the JSONObject
 * and won't put the null value in the container.
 * As {@link ConcurrentHashMap#putAll(Map)} will throws an exception if the key or value to
 * be put is null, it is necessary to invoke this method as replacement of
 * {@link Map#putAll(Map)}
 * @param container container to contain the JSONObject.
 * @param rawValue jsonObject, contains map info.
 */
public static void putAll(Map<String, Object> container, JSONObject rawValue) {
  String key;
  Object value;
  for (Map.Entry<String, Object> entry : rawValue.entrySet()) {
    key = entry.getKey();
    value = entry.getValue();
    if (key != null && value != null) {
      container.put(key, value);
    }
  }
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:22,代碼來源:WXJsonUtils.java

示例9: testJSONToResult

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
@Test
public void testJSONToResult() {
    String json = "[{\"host\":\"127.0.0.1\"},{\"host\":\"127.0.0.1\"},{\"host\":\"127.0.0.1.012\"}]";

    try {
        JSONArray array = JSON.parseArray(json);
        // System.out.println(array);
        Assert.assertEquals(array.toString(),
                "[{\"host\":\"127.0.0.1\"},{\"host\":\"127.0.0.1\"},{\"host\":\"127.0.0.1.012\"}]");
        List<TagResult> arrayList = new ArrayList<TagResult>(array.size());

        Iterator<Object> iterator = array.iterator();
        while (iterator.hasNext()) {
            JSONObject object = (JSONObject) iterator.next();
            Set<Entry<String, Object>> entrySet = object.entrySet();
            for (Entry<String, Object> entry : entrySet) {
                String key = entry.getKey();
                Assert.assertNotEquals(key, null);
                Object valueObject = entry.getValue();
                Assert.assertNotEquals(key, null);
                String value = valueObject.toString();
                TagResult tagResult = new TagResult(key, value);
                arrayList.add(tagResult);
                break;
            }
        }
        Assert.assertEquals(arrayList.size(), 3);
    } catch (Exception ex) {
        ex.printStackTrace();
    }

}
 
開發者ID:aliyun,項目名稱:HiTSDB-Client,代碼行數:33,代碼來源:TestTagResult.java

示例10: json2Map

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
public static Map<String,Object> json2Map(String json){
    if (StringUtils.isEmpty(json)){
        return null;
    }
    JSONObject object = str2Json(json);
    Map<String,Object> jsonMap = new HashMap<String,Object>();
    for (Map.Entry<String,Object> entry:object.entrySet()){
        jsonMap.put(entry.getKey(),entry.getValue());
    }
    return jsonMap;
}
 
開發者ID:rpgmakervx,項目名稱:slardar,代碼行數:12,代碼來源:JsonUtils.java

示例11: compactConvert

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
private JSONObject compactConvert(JSONObject jsonObject) {
    val compactJsonObject = new JSONObject();
    for (val entry : jsonObject.entrySet()) {
        Object value = entry.getValue();
        if (value instanceof JSONArray) {
            value = compactConvert((JSONArray) value);
        } else if (value instanceof JSONObject) {
            value = compactConvert((JSONObject) value);
        }

        compactJsonObject.put(entry.getKey(), value);
    }

    return compactJsonObject;
}
 
開發者ID:bingoohuang,項目名稱:westjson,代碼行數:16,代碼來源:WestJsonCompacter.java

示例12: unthin

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
private JSON unthin(JSONObject origin) {
    JSONObject unmapped = new JSONObject();
    for (val item : origin.entrySet()) {
        Object value = item.getValue();
        String key = item.getKey();
        String mappedKey = keyMapping.get(key);
        mappedKey = mappedKey == null ? key : mappedKey;
        unmapped.put(mappedKey, unthin(value, true));
    }

    return unmapped;
}
 
開發者ID:bingoohuang,項目名稱:westjson,代碼行數:13,代碼來源:WestJsonUnthiner.java

示例13: insert

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/**
   * <B>方法名稱:</B>單表INSERT方法<BR>
   * <B>概要說明:</B>單表INSERT方法<BR>
   * @param tableName 表名
   * @param data JSONObject對象
   */
  protected int insert(String tableName, JSONObject data) {
      
  	if (data.size() <= 0) {
          return 0;
      }
  	
      StringBuffer sql = new StringBuffer();
      sql.append(" INSERT INTO ");
      sql.append(tableName + " ( ");
  	
  	Set<Entry<String, Object>> set = data.entrySet();
  	List<Object> sqlArgs = new ArrayList<Object>();
  	for (Iterator<Entry<String, Object>> iterator = set.iterator(); iterator.hasNext();) {
	Entry<String, Object> entry = (Entry<String, Object>) iterator.next();
	sql.append(entry.getKey() + ",");
	sqlArgs.add(entry.getValue());
}

      sql.delete(sql.length() - 1, sql.length());
      sql.append(" ) VALUES ( ");
      for (int i = 0; i < set.size(); i++) {
          sql.append("?,");
      }
      
      sql.delete(sql.length() - 1, sql.length());
      sql.append(" ) ");
      
      return this.getJdbcTemplate().update(sql.toString(), sqlArgs.toArray()); 
  }
 
開發者ID:craware,項目名稱:webapp-tyust,代碼行數:36,代碼來源:BaseJdbcDao.java

示例14: getCollections

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
private Map<String, ConfigValueReference> getCollections(String baseUrl, String configCollectionId, String configCollectionVersion) {
    Map<String, String> params = new HashMap<>(1<<4);
    params.put("configAppId", configCollectionId);
    params.put("configAppVersion", configCollectionVersion);
    String content = WxzConfHttpClient.getContent(baseUrl + "/listConfigs", params);
    JSONObject jsonObject = JSONObject.parseObject(content);
    Map<String, ConfigValueReference> res = new LinkedHashMap<>();
    for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
        res.put(entry.getKey(), new ConfigValueReference(entry.getKey(), entry.getValue().toString()));
    }
    return Collections.unmodifiableMap(res);
}
 
開發者ID:wxz1211,項目名稱:dooo,代碼行數:13,代碼來源:RemoteConfigCollectionCache.java

示例15: __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.entrySet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。