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