org.json.JSONObject.entrySet()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(400)

本文整理了Java中org.json.JSONObject.entrySet()方法的一些代码示例,展示了JSONObject.entrySet()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONObject.entrySet()方法的具体详情如下:
包路径:org.json.JSONObject
类名称:JSONObject
方法名:entrySet

JSONObject.entrySet介绍

[英]Get a set of entries of the JSONObject. These are raw values and may not match what is returned by the JSONObject get* and opt* functions. Modifying the returned EntrySet or the Entry objects contained therein will modify the backing JSONObject. This does not return a clone or a read-only view. Use with caution.
[中]获取JSONObject的一组条目。这些是原始值,可能与JSONObject get和opt函数返回的值不匹配。修改返回的EntrySet或其中包含的Entry对象将修改支持JSONObject。这不会返回克隆或只读视图。小心使用。

代码示例

代码示例来源:origin: loklak/loklak_server

/**
   * Returns a java.util.Map containing all of the entries in this object.
   * If an entry in the object is a JSONArray or JSONObject it will also
   * be converted.
   * <p>
   * Warning: This method assumes that the data structure is acyclical.
   *
   * @return a java.util.Map containing the entries of this object
   */
  public Map<String, Object> toMap() {
    Map<String, Object> results = new HashMap<String, Object>();
    for (Entry<String, Object> entry : this.entrySet()) {
      Object value;
      if (entry.getValue() == null || NULL.equals(entry.getValue())) {
        value = null;
      } else if (entry.getValue() instanceof JSONObject) {
        value = ((JSONObject) entry.getValue()).toMap();
      } else if (entry.getValue() instanceof JSONArray) {
        value = ((JSONArray) entry.getValue()).toList();
      } else {
        value = entry.getValue();
      }
      results.put(entry.getKey(), value);
    }
    return results;
  }
}

代码示例来源:origin: loklak/loklak_server

for (final Entry<String, ?> entry : jo.entrySet()) {
  final String key = entry.getKey();
  if (!"tagName".equals(key) && !"childNodes".equals(key)) {

代码示例来源:origin: loklak/loklak_server

for (final Entry<String, ?> entry : jo.entrySet()) {
  final String key = entry.getKey();
  Object value = entry.getValue();

代码示例来源:origin: loklak/loklak_server

for (final Entry<String, ?> entry : jo.entrySet()) {
  final String key = entry.getKey();
  XML.noSpace(key);

代码示例来源:origin: loklak/loklak_server

return false;
for (final Entry<String,?> entry : this.entrySet()) {
  String name = entry.getKey();
  Object valueThis = entry.getValue();

代码示例来源:origin: loklak/loklak_server

final Entry<String,?> entry = this.entrySet().iterator().next();
final String key = entry.getKey();
writer.write(quote(key));
for (final Entry<String,?> entry : this.entrySet()) {
  if (commanate) {
    writer.write(',');

代码示例来源:origin: b3log/latke

/**
   * Returns a java.util.Map containing all of the entries in this object.
   * If an entry in the object is a JSONArray or JSONObject it will also
   * be converted.
   * <p>
   * Warning: This method assumes that the data structure is acyclical.
   *
   * @return a java.util.Map containing the entries of this object
   */
  public Map<String, Object> toMap() {
    Map<String, Object> results = new HashMap<String, Object>();
    for (Entry<String, Object> entry : this.entrySet()) {
      Object value;
      if (entry.getValue() == null || NULL.equals(entry.getValue())) {
        value = null;
      } else if (entry.getValue() instanceof JSONObject) {
        value = ((JSONObject) entry.getValue()).toMap();
      } else if (entry.getValue() instanceof JSONArray) {
        value = ((JSONArray) entry.getValue()).toList();
      } else {
        value = entry.getValue();
      }
      results.put(entry.getKey(), value);
    }
    return results;
  }
}

代码示例来源:origin: b3log/latke

return false;
for (final Entry<String,?> entry : this.entrySet()) {
  String name = entry.getKey();
  Object valueThis = entry.getValue();

代码示例来源:origin: b3log/latke

final Entry<String,?> entry = this.entrySet().iterator().next();
final String key = entry.getKey();
writer.write(quote(key));
for (final Entry<String,?> entry : this.entrySet()) {
  if (commanate) {
    writer.write(',');

代码示例来源:origin: stackoverflow.com

JSONObject jsonRootObj = JSON.parseObject(completeJson);
JSONObject a1 = jsonRootObj.getJSONObject("a1");
JSONObject a2 = jsonRootObj.getJSONObject("a2");
for (Map.Entry<String, Object> entry : a1.entrySet()) {
  if (a2.containsKey(entry.getKey())) {
    a2.put(entry.getKey(), entry.getValue());
  }
}

代码示例来源:origin: org.b3log/latke

/**
   * Returns a java.util.Map containing all of the entries in this object.
   * If an entry in the object is a JSONArray or JSONObject it will also
   * be converted.
   * <p>
   * Warning: This method assumes that the data structure is acyclical.
   *
   * @return a java.util.Map containing the entries of this object
   */
  public Map<String, Object> toMap() {
    Map<String, Object> results = new HashMap<String, Object>();
    for (Entry<String, Object> entry : this.entrySet()) {
      Object value;
      if (entry.getValue() == null || NULL.equals(entry.getValue())) {
        value = null;
      } else if (entry.getValue() instanceof JSONObject) {
        value = ((JSONObject) entry.getValue()).toMap();
      } else if (entry.getValue() instanceof JSONArray) {
        value = ((JSONArray) entry.getValue()).toList();
      } else {
        value = entry.getValue();
      }
      results.put(entry.getKey(), value);
    }
    return results;
  }
}

代码示例来源:origin: stackoverflow.com

while (iterator.hasNext()) {
  JSONObject jsonObject1 = ((JSONObject) iterator.next());
  Iterator<? extends Map.Entry<Object, Object> > it = jsonObject1.entrySet().iterator();
  while(it.hasNext()) {
    String name = null, enchantType = null;

代码示例来源:origin: org.b3log/latke

return false;
for (final Entry<String,?> entry : this.entrySet()) {
  String name = entry.getKey();
  Object valueThis = entry.getValue();

代码示例来源:origin: org.b3log/latke

final Entry<String,?> entry = this.entrySet().iterator().next();
final String key = entry.getKey();
writer.write(quote(key));
for (final Entry<String,?> entry : this.entrySet()) {
  if (commanate) {
    writer.write(',');

相关文章

微信公众号

最新文章

更多

JSONObject类方法