org.eclipse.ditto.json.JsonObject.getKeys()方法的使用及代码示例

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

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

JsonObject.getKeys介绍

[英]Returns a list of the keys in this JSON object in document order. The returned list cannot be used to modify this JSON object.
[中]按文档顺序返回此JSON对象中的键列表。返回的列表不能用于修改此JSON对象。

代码示例

代码示例来源:origin: org.eclipse.ditto/ditto-model-things

@Override
public List<JsonKey> getKeys() {
  return wrapped.getKeys();
}

代码示例来源:origin: org.eclipse.ditto/ditto-model-things

@Override
public List<JsonKey> getKeys() {
  return wrapped.getKeys();
}

代码示例来源:origin: eclipse/ditto

@Override
public List<JsonKey> getKeys() {
  return wrapped.getKeys();
}

代码示例来源:origin: eclipse/ditto

@Override
public List<JsonKey> getKeys() {
  return wrapped.getKeys();
}

代码示例来源:origin: eclipse/ditto

private static void handleObject(final String path, final JsonValue value, final List<Document> flatAttributes) {
  final JsonObject jsonObject = value.asObject();
  jsonObject.getKeys().forEach(key -> {
    final String newPath = path + PersistenceConstants.SLASH + key;
    final JsonValue innerValue = jsonObject.getValue(key).orElse(null);
    toFlatAttributesList(newPath, innerValue, flatAttributes);
  });
}

代码示例来源:origin: org.eclipse.ditto/ditto-services-thingsearch-persistence

private static void handleObject(final String path, final JsonValue value, final List<Document> flatAttributes) {
  final JsonObject jsonObject = value.asObject();
  jsonObject.getKeys().forEach(key -> {
    final String newPath = path + PersistenceConstants.SLASH + key;
    final JsonValue innerValue = jsonObject.getValue(key).orElse(null);
    toFlatAttributesList(newPath, innerValue, flatAttributes);
  });
}

代码示例来源:origin: org.eclipse.ditto/ditto-services-thingsearch-persistence

private void addInternalAttributes(final String path, final JsonValue jsonValue) {
  if ((jsonValue == null) || jsonValue.isNull()) {
    attributeInternally(path, null);
  } else if (jsonValue.isString()) {
    attributeInternally(path, jsonValue.asString());
  } else if (jsonValue.isBoolean()) {
    attributeInternally(path, jsonValue.asBoolean());
  } else if (jsonValue.isNumber()) {
    addNumberAttribute(path, jsonValue);
  } else if (jsonValue.isObject()) {
    jsonValue.asObject().getKeys().forEach(key -> //
        addInternalAttributes(path + PersistenceConstants.SLASH + key, jsonValue.asObject().getValue(key).orElse(null)));
  }
}

代码示例来源:origin: eclipse/ditto

private void addInternalAttributes(final String path, final JsonValue jsonValue) {
  if (jsonValue == null || jsonValue.isNull()) {
    attributeInternally(path, null);
  } else if (jsonValue.isString()) {
    attributeInternally(path, jsonValue.asString());
  } else if (jsonValue.isBoolean()) {
    attributeInternally(path, jsonValue.asBoolean());
  } else if (jsonValue.isNumber()) {
    addNumberAttribute(path, jsonValue);
  } else if (jsonValue.isObject()) {
    jsonValue.asObject().getKeys().forEach(key -> //
        addInternalAttributes(path + PersistenceConstants.SLASH + key, jsonValue.asObject().getValue(key).orElse(null)));
  }
}

代码示例来源:origin: org.eclipse.ditto/ditto-services-thingsearch-persistence

private void addInternalFeatures(final String path, final JsonValue jsonValue, final String featureId) {
  if ((jsonValue == null) || jsonValue.isNull()) {
    featureInternally(path, null, featureId);
  } else if (jsonValue.isString()) {
    featureInternally(path, jsonValue.asString(), featureId);
  } else if (jsonValue.isBoolean()) {
    featureInternally(path, jsonValue.asBoolean(), featureId);
  } else if (jsonValue.isNumber()) {
    addNumberFeature(path, jsonValue, featureId);
  } else if (jsonValue.isObject()) {
    jsonValue.asObject().getKeys().forEach(name -> //
        addInternalFeatures(path + "/" + name, jsonValue.asObject().getValue(name).orElse(null),
            featureId));
  }
}

代码示例来源:origin: eclipse/ditto

private void addInternalFeatures(final String path, final JsonValue jsonValue, final String featureId) {
  if ((jsonValue == null) || jsonValue.isNull()) {
    featureInternally(path, null, featureId);
  } else if (jsonValue.isString()) {
    featureInternally(path, jsonValue.asString(), featureId);
  } else if (jsonValue.isBoolean()) {
    featureInternally(path, jsonValue.asBoolean(), featureId);
  } else if (jsonValue.isNumber()) {
    addNumberFeature(path, jsonValue, featureId);
  } else if (jsonValue.isObject()) {
    jsonValue.asObject().getKeys().forEach(name -> //
        addInternalFeatures(path + "/" + name, jsonValue.asObject().getValue(name).orElse(null),
            featureId));
  }
}

代码示例来源:origin: eclipse/ditto

/**
 * Verifies that the actual JSON object contains the expected value for the specified key.
 *
 * @param key the key of the expected value.
 * @param expectedValue the expected value to be associated with {@code key}.
 * @return this assert to allow method chaining.
 */
public JsonObjectAssert contains(final JsonKey key, final JsonValue expectedValue) {
  isNotNull();
  final List<JsonKey> actualNames = actual.getKeys();
  Assertions.assertThat(actualNames).contains(key)
      .overridingErrorMessage("Expected JSON object to contain a field with name <%s> but it did not.",
          key);
  final Optional<JsonValue> actualValue = actual.getValue(key);
  assertThat(actualValue)
      .overridingErrorMessage("Expected JSON object to contain value <%s> for key <%s> but the actual value" +
          " was <%s>", expectedValue, key, actualValue.orElse(null))
      .contains(expectedValue);
  return this;
}

相关文章