com.google.gwt.json.client.JSONObject.keySet()方法的使用及代码示例

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

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

JSONObject.keySet介绍

[英]Returns the set of properties defined on this JSONObject. The returned set is immutable.
[中]返回在此JSONObject上定义的属性集。返回的集合是不可变的。

代码示例

代码示例来源:origin: org.jboss.errai/errai-marshalling

@Override
public Set<String> keySet() {
 return obj.keySet();
}

代码示例来源:origin: errai/errai

@Override
public Set<String> keySet() {
 return obj.keySet();
}

代码示例来源:origin: org.codehaus.sonar/sonar-gwt-api

@Override
public Set<String> getFields(Object json) {
 return ((JSONObject) json).keySet();
}

代码示例来源:origin: org.jboss.errai/errai-jaxrs-client

private static JSONObject cleanUpEmbeddedJson(JSONObject obj) {
 if (obj != null) {
  for (String k : obj.keySet()) {
   if (k.startsWith(SerializationParts.EMBEDDED_JSON)) {
    obj.put(k, null);
   }
  }
 }
 return obj;
}

代码示例来源:origin: org.jbpm/jbpm-gwt-form-api

private Map<String, Object> asMap(JSONObject jsonObj) {
  Map<String, Object> retval = new HashMap<String, Object>();
  for (String key : jsonObj.keySet()) {
    JSONValue value = jsonObj.get(key);
    retval.put(key, fromJsonValue(value));
  }
  return retval;
}

代码示例来源:origin: org.eclipse.che.core/che-core-ide-app

private static Map<String, JSONValue> readPreferencesFromJson(String jsonPreferences) {
  Map<String, JSONValue> result = new HashMap<>();
  JSONValue parsed = JSONParser.parseStrict(jsonPreferences);

  JSONObject jsonObj = parsed.isObject();
  if (jsonObj != null) {
   jsonObj.keySet().forEach(key -> result.put(key, jsonObj.get(key)));
  }
  return result;
 }
}

代码示例来源:origin: org.eclipse.che.core/che-core-ide-app

private static Map<String, JSONValue> readPropertiesFromJson(String jsonProperties) {
  Map<String, JSONValue> result = new HashMap<>();
  JSONValue parsed = JSONParser.parseStrict(jsonProperties);

  JSONObject jsonObj = parsed.isObject();
  if (jsonObj != null) {
   for (String key : jsonObj.keySet()) {
    JSONValue jsonValue = jsonObj.get(key);
    result.put(key, jsonValue);
   }
  }
  return result;
 }
}

代码示例来源:origin: sk.seges.acris/acris-site-core

public final Map<String, Integer> getStringIntMap(String key) {
  if (!hasKey(key)) {
    return null;
  }
  Map<String, Integer> map = new HashMap<String, Integer>();
  JSONObject object = new JSONObject(this);
  JSONObject value = (JSONObject) object.get(key);
  Set<String> keys = value.keySet();
  for (String string : keys) {
    JSONNumber jValue = value.get(string).isNumber();
    map.put(string, Double.valueOf(jValue.doubleValue()).intValue());
  }
  return map;
}

代码示例来源:origin: sk.seges.acris/acris-site-core

public final Map<String, String> getStringStringMap(String key) {
  if (!hasKey(key)) {
    return null;
  }
  Map<String, String> map = new HashMap<String, String>();
  JSONObject object = new JSONObject(this);
  JSONObject value = (JSONObject) object.get(key);
  Set<String> keys = value.keySet();
  for (String string : keys) {
    JSONString jValue = value.get(string).isString();
    map.put(string, jValue.stringValue());
  }
  return map;
}

代码示例来源:origin: kiegroup/appformer

public final PlaceRequest toPlaceRequest() {
    JSONObject rawParams = new JSONObject(getParams());
    Map<String, String> params = new HashMap<String, String>();
    for (String key : rawParams.keySet()) {
      params.put(key,
            rawParams.get(key).isString().stringValue());
    }
    return new DefaultPlaceRequest(getIdentifier(),
                    params);
  }
}

代码示例来源:origin: org.jbpm/jbpm-gwt-form-api

public Map<String, OutputData> decodeOutputs(JSONValue json)
    throws FormEncodingException {
  Map<String, OutputData> retval = new HashMap<String, OutputData>();
  if (json != null && json.isObject() != null) {
    for (String key : json.isObject().keySet()) {
      JSONValue value = json.isObject().get(key);
      if (value.isObject() != null) {
        JSONObject jsonObj = value.isObject();
        retval.put(key, (OutputData) decode(asMap(jsonObj)));
      }
    }
  }
  return retval;
}

代码示例来源:origin: org.jbpm/jbpm-gwt-form-api

public Map<String, InputData> decodeInputs(JSONValue json)
    throws FormEncodingException {
  Map<String, InputData> retval = new HashMap<String, InputData>();
  if (json != null && json.isObject() != null) {
    for (String key : json.isObject().keySet()) {
      JSONValue value = json.isObject().get(key);
      if (value.isObject() != null) {
        JSONObject jsonObj = value.isObject();
        retval.put(key, (InputData) decode(asMap(jsonObj)));
      }
    }
  }
  return retval;
}

代码示例来源:origin: bedatadriven/activityinfo

static ColumnSet fromJson(String json) {
  try {
    JSONObject jsonObject = JSONParser.parseStrict(json).isObject();
    int rowsCount = (int) jsonObject.get("rows").isNumber().doubleValue();
    Map<String, ColumnView> views = Maps.newHashMap();
    JSONObject jsonColumns = jsonObject.get("columns").isObject();
    for (String columnId : jsonColumns.keySet()) {
      views.put(columnId, parseColumn(rowsCount, jsonColumns.get(columnId).isObject()));
    }
    return new ColumnSet(rowsCount, views);
  } catch (Exception e) {
    LOGGER.log(Level.SEVERE, "Failed to parse column set: " + e.getMessage() + "\n" + json, e);
    throw e;
  }
}

代码示例来源:origin: com.github.zerkseez/gwtpojo-core

@Override
  public Map<K, V> deserialize(final JSONValue jsonValue) {
    if (jsonValue == null || jsonValue.isNull() != null) {
      return null;
    }

    final JSONObject jsonObject = jsonValue.isObject();
    if (jsonObject == null) {
      throw new GWTPojoSerializerException("Unable to deserialize " + jsonValue.toString() + " as Map<?, ?>");
    }

    final Map<K, V> map = new HashMap<K, V>();
    for (String keyString : jsonObject.keySet()) {
      final K key = kSerializer.deserialize(new JSONString(keyString));
      final V value = vSerializer.deserialize(jsonObject.get(keyString));
      map.put(key, value);
    }
    return map;
  }
}

代码示例来源:origin: org.eclipse.che.plugin/che-plugin-java-ext-lang-client

public static JavaCoreOptionsDto fromJson(JSONValue jsonVal) {
    if (jsonVal == null) {
      return null;
    }
    JSONObject json= jsonVal.isObject();
    JavaCoreOptionsDto result= new JavaCoreOptionsDto();
    JSONValue jsonoptionsJson = json.get("options");
    if (jsonoptionsJson != null && !(jsonoptionsJson.isNull() != null)) {
      java.util.Map<java.lang.String, java.lang.String> jsonoptionsVal= new HashMap<String, java.lang.String>();
      JSONObject jsonoptionsValo = jsonoptionsJson.isObject();
      for(String jsonoptionsValok : jsonoptionsValo.keySet()) {
        java.lang.String jsonoptionsValoX = jsonoptionsValo.get(jsonoptionsValok).isString().stringValue();;
        jsonoptionsVal.put(jsonoptionsValok, jsonoptionsValoX);
      }
      result.setOptions((java.util.Map<java.lang.String, java.lang.String>)jsonoptionsVal);
    }
    return result;
  }
}

代码示例来源:origin: org.uberfire/uberfire-layout-editor-client

private LayoutDragComponent getLayoutDragComponent(JSONObject jsonObject,
                          String type) {
  LayoutDragComponent dragComponent = getLayoutDragComponent(type);
  if (dragComponent instanceof HasDragAndDropSettings) {
    HasDragAndDropSettings sComponent = (HasDragAndDropSettings) dragComponent;
    JSONObject params = jsonObject.get(COMPONENT_PARAMS).isObject();
    if (params != null) {
      for (String key : params.keySet()) {
        JSONString value = params.get(key).isString();
        if (value != null) {
          sComponent.setSettingValue(key,
                        value.stringValue());
        }
      }
    }
  }
  return dragComponent;
}

代码示例来源:origin: kiegroup/appformer

private LayoutDragComponent getLayoutDragComponent(JSONObject jsonObject,
                          String type) {
  LayoutDragComponent dragComponent = getLayoutDragComponent(type);
  if (dragComponent instanceof HasDragAndDropSettings) {
    HasDragAndDropSettings sComponent = (HasDragAndDropSettings) dragComponent;
    JSONObject params = jsonObject.get(COMPONENT_PARAMS).isObject();
    if (params != null) {
      for (String key : params.keySet()) {
        JSONString value = params.get(key).isString();
        if (value != null) {
          sComponent.setSettingValue(key,
                        value.stringValue());
        }
      }
    }
  }
  return dragComponent;
}

代码示例来源:origin: org.jboss.as/jboss-as-console-dmr

private String extractFailure(final JSONObject response) {
  String failure = "n/a";
  JSONValue failureValue = response.get(FAILURE_DESCRIPTION);
  if (failureValue.isString() != null) {
    failure = failureValue.isString().stringValue();
  } else if (failureValue.isObject() != null) {
    JSONObject failureObject = failureValue.isObject();
    for (String key : failureObject.keySet()) {
      if (key.contains("failure") && failureObject.get(key).isString() != null) {
        failure = failureObject.get(key).isString().stringValue();
        break;
      }
    }
  }
  return failure;
}

代码示例来源:origin: kiegroup/appformer

public static void fire(HasDataSelectionEventHandlers source, Object sender, JavaScriptObject data) {
  DataSelectionEvent event = new DataSelectionEvent(sender);
  JSONObject array = new JSONObject(data);
  event.series = new LinkedList<Series>();
  for(String key : array.keySet()){
    JSONObject obj = array.get(key).isObject();
    if(obj != null){
      Series series1 = JavaScriptObject.createObject().cast();
      series1.setValue(obj.get("value").isNumber().doubleValue());
      series1.setColor(obj.get("fillColor").isString().stringValue());
      event.series.add(series1);
    }
  }
  source.fireEvent(event);
}

代码示例来源:origin: ArcBees/GWTP

/**
 * Used to deserialize the bindings once on the client. Usage of GWT code is allowed.
 */
public RestParameterBindings deserialize(String encodedParameters) {
  RestParameterBindings parameters = new RestParameterBindings();
  JSONObject json = JSONParser.parseStrict(encodedParameters).isObject();
  for (String method : json.keySet()) {
    HttpMethod httpMethod = HttpMethod.valueOf(method);
    JSONArray jsonParameters = json.get(method).isArray();
    for (int i = 0; i < jsonParameters.size(); ++i) {
      HttpParameter parameter = deserialize(jsonParameters.get(i).isObject());
      parameters.put(httpMethod, parameter);
    }
  }
  return parameters;
}

相关文章