elemental.json.JsonObject.keys()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(131)

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

JsonObject.keys介绍

[英]All keys of the object.
[中]对象的所有关键点。

代码示例

代码示例来源:origin: com.vaadin/vaadin-server

private static boolean jsonObjectEquals(JsonObject a, JsonObject b) {
  String[] keys = a.keys();
  if (keys.length != b.keys().length) {
    return false;
  }
  for (String key : keys) {
    JsonValue value = b.get(key);
    if (value == null || !jsonEquals(a.get(key), value)) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: com.vaadin/vaadin-server

private static Map<Object, Object> decodeStringMap(Type valueType,
    JsonObject jsonMap, ConnectorTracker connectorTracker) {
  Map<Object, Object> map = new HashMap<>();
  for (String key : jsonMap.keys()) {
    Object value = decodeInternalOrCustomType(valueType,
        jsonMap.get(key), connectorTracker);
    if (valueType == UidlValue.class) {
      value = ((UidlValue) value).getValue();
    }
    map.put(key, value);
  }
  return map;
}

代码示例来源:origin: com.vaadin/vaadin-server

private static Map<Object, Object> decodeConnectorMap(Type valueType,
    JsonObject jsonMap, ConnectorTracker connectorTracker) {
  Map<Object, Object> map = new HashMap<>();
  for (String key : jsonMap.keys()) {
    Object value = decodeInternalOrCustomType(valueType,
        jsonMap.get(key), connectorTracker);
    if (valueType == UidlValue.class) {
      value = ((UidlValue) value).getValue();
    }
    map.put(connectorTracker.getConnector(key), value);
  }
  return map;
}

代码示例来源:origin: com.vaadin/vaadin-server

JsonObject stateJson = connector.encodeState();
if (stateJson != null && stateJson.keys().length != 0) {
  sharedStates.put(connectorId, stateJson);
  writtenConnectors.add(connectorId);

代码示例来源:origin: com.vaadin/hummingbird-server

private static boolean jsonObjectEquals(JsonObject a, JsonObject b) {
  assert a != null;
  assert b != null;
  if (a == b) {
    return true;
  }
  String[] keys = a.keys();
  if (keys.length != b.keys().length) {
    return false;
  }
  for (String key : keys) {
    JsonValue value = b.get(key);
    if (value == null || !jsonEquals(a.get(key), value)) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: com.vaadin/flow-server

private static boolean jsonObjectEquals(JsonObject a, JsonObject b) {
  assert a != null;
  assert b != null;
  if (a == b) {
    return true;
  }
  String[] keys = a.keys();
  if (keys.length != b.keys().length) {
    return false;
  }
  for (String key : keys) {
    JsonValue value = b.get(key);
    if (value == null || !jsonEquals(a.get(key), value)) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: com.googlecode.gwtquery/gwtquery

private void stripProxy(JsonBuilder proxy) throws Throwable {
 Class<?> type = proxy.getClass().getInterfaces()[0];
 HashSet<String> validAttrs = getAttributeNames(type.getMethods());
 Hashtable<String, Method> ispropertyGetters = getJsonBuilders(type.getMethods());
 for (String key : jsonObject.keys()) {
  String name = methodName2AttrName(key);
  if (!validAttrs.contains(name)) {
   jsonObject.remove(key);
   continue;
  }
  Method ispropertyGetter = ispropertyGetters.get(name);
  if (ispropertyGetter != null) {
   ((IsProperties) invoke(proxy, ispropertyGetter, new Object[] {})).strip();
  }
 }
}

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

@Override
public void onWindowClosing(WindowActionEvent event) {
 if (appContext.getWorkspace() == null) {
  return;
 }
 JsonObject appState = appStateManager.collectAppStateData();
 if (appState.keys().length > 0) {
  appStateSyncWriter.saveState(appState);
 }
}

代码示例来源:origin: org.eclipse.che.plugin/che-plugin-yaml-ide

/**
 * Converts json string to list of Yaml Preferences
 *
 * @param jsonStr The json string to turn into the list of Yaml Preferences
 * @return List of Yaml Preferences
 */
private List<YamlPreference> jsonToYamlPreference(String jsonStr) {
 ArrayList yamlPreferences = new ArrayList<YamlPreference>();
 JsonObject parsedJson = Json.parse(jsonStr);
 for (String glob : parsedJson.keys()) {
  try {
   JsonArray jsonArray = parsedJson.getArray(glob);
   for (int arrNum = 0; arrNum < jsonArray.length(); arrNum++) {
    YamlPreference newYamlPref = new YamlPreference(jsonArray.getString(arrNum), glob);
    yamlPreferences.add(newYamlPref);
   }
  } catch (Exception e) {
   LOG.debug(e.getMessage(), e);
  }
 }
 return yamlPreferences;
}

代码示例来源:origin: com.googlecode.gwtquery/gwtquery

return jsonObject.keys();
} else if ("as".equals(mname)) {
 @SuppressWarnings("unchecked")

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

/**
 * Determines whether perspective is maximized.
 *
 * @param partStacksState part stack state
 * @return <b>true</b> is perspective has maximized part stack
 */
private boolean isPerspectiveMaximized(JsonObject partStacksState) {
 for (String partStackType : partStacksState.keys()) {
  JsonObject partStackState = partStacksState.getObject(partStackType);
  if (partStackState.hasKey(PART_STACK_STATE)
    && PartStack.State.MAXIMIZED.name().equals(partStackState.getString(PART_STACK_STATE))) {
   return true;
  }
 }
 return false;
}

代码示例来源:origin: com.vaadin/flow-data

@Override
public void generateData(T item, JsonObject data) {
  JsonValue value = JsonSerializer.toJson(item);
  if (value instanceof JsonObject) {
    JsonObject object = (JsonObject) value;
    for (String key : object.keys()) {
      data.put(key, (JsonValue) object.get(key));
    }
  } else {
    data.put("value", value);
  }
}

代码示例来源:origin: com.googlecode.gwtquery/gwtquery

private String param(JsonObject o) {
 String ret = "";
 for (String k : o.keys()) {
  ret += ret.isEmpty() ? "" : "&";
  JsonValue v = o.get(k);
  if (v instanceof JsonArray) {
   for (int i = 0, l = ((JsonArray) v).length(); i < l; i++) {
    ret += i > 0 ? "&" : "";
    JsonValue e = ((JsonArray) v).get(i);
    ret += k + "[]=" + e.toJson();
   }
  } else {
   if (v != null && !(v instanceof JsonNull)) {
    ret += k + "=" + v.toJson();
   }
  }
 }
 return ret;
}

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

@Override
public Promise<Void> loadState(JsonObject state) {
 if (state.hasKey(PERSPECTIVES)) {
  JsonObject perspectives = state.getObject(PERSPECTIVES);
  Map<String, Perspective> perspectiveMap = perspectiveManagerProvider.get().getPerspectives();
  ArrayOf<Promise<?>> perspectivePromises = Collections.arrayOf();
  for (String key : perspectives.keys()) {
   if (perspectiveMap.containsKey(key)) {
    perspectivePromises.push(perspectiveMap.get(key).loadState(perspectives.getObject(key)));
   }
  }
  return promises.all2(perspectivePromises).thenPromise(ignored -> promises.resolve(null));
 }
 return promises.resolve(null);
}

代码示例来源:origin: com.vaadin/vaadin-date-picker-flow

/**
 * Sets the internationalization properties for this component.
 *
 * @param i18n
 *            the internationalized properties, not <code>null</code>
 */
public void setI18n(DatePickerI18n i18n) {
  Objects.requireNonNull(i18n,
      "The I18N properties object should not be null");
  this.i18n = i18n;
  runBeforeClientResponse(ui -> {
    if (i18n == this.i18n) {
      JsonObject i18nObject = (JsonObject) JsonSerializer
          .toJson(this.i18n);
      for (String key : i18nObject.keys()) {
        ui.getPage().executeJavaScript(
            "$0.set('i18n." + key + "', $1)", getElement(),
            i18nObject.get(key));
      }
    }
  });
}

代码示例来源:origin: com.vaadin/vaadin-upload-flow

/**
 * Set the internationalization properties for this component.
 *
 * @param i18n
 *            the internationalized properties, not <code>null</code>
 */
public void setI18n(UploadI18N i18n) {
  Objects.requireNonNull(i18n,
      "The I18N properties object should not be null");
  this.i18n = i18n;
  runBeforeClientResponse(ui -> {
    if (i18n == this.i18n) {
      JsonObject i18nObject = (JsonObject) JsonSerializer
        .toJson(this.i18n);
      for (String key : i18nObject.keys()) {
        ui.getPage().executeJavaScript(
            "$0.set('i18n." + key + "', $1)", getElement(),
            i18nObject.get(key));
      }
    }
  });
}

代码示例来源:origin: com.vaadin/vaadin-rich-text-editor-flow

/**
 * Sets the internationalization properties for this component.
 *
 * @param i18n
 *            the internationalized properties, not <code>null</code>
 */
public void setI18n(RichTextEditorI18n i18n) {
  Objects.requireNonNull(i18n,
      "The I18N properties object should not be null");
  this.i18n = i18n;
  runBeforeClientResponse(ui -> {
    if (i18n == this.i18n) {
      JsonObject i18nObject = (JsonObject) JsonSerializer
          .toJson(this.i18n);
      for (String key : i18nObject.keys()) {
        ui.getPage().executeJavaScript(
            "$0.set('i18n." + key + "', $1)", getElement(),
            i18nObject.get(key));
      }
    }
  });
}

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

try {
 Promise<Void> sequentialRestore = promises.resolve(null);
 for (String key : appState.keys()) {
  Optional<StateComponent> stateComponent =
    stateComponentRegistry.get().getComponentById(key);

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

for (String partStackType : partStacksState.keys()) {
 JsonObject partStackState = partStacksState.getObject(partStackType);
 switch (PartStackType.valueOf(partStackType)) {

代码示例来源:origin: com.vaadin/vaadin-compatibility-server

&& cellDescriptions.keys().length > 0) {
  rowData.put(GridState.JSONKEY_CELLDESCRIPTION,
      cellDescriptions);
if (cellStyleGenerator != null && cellStyles.keys().length > 0) {
  rowData.put(GridState.JSONKEY_CELLSTYLES, cellStyles);

相关文章