com.couchbase.client.java.document.json.JsonObject.getNames()方法的使用及代码示例

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

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

JsonObject.getNames介绍

[英]Returns a set of field names on the JsonObject.
[中]返回JsonObject上的一组字段名。

代码示例

代码示例来源:origin: brianfrankcooper/YCSB

value = value.getObject(bucketName);
Set<String> f = allFields ? value.getNames() : fields;
HashMap<String, ByteIterator> tuple = new HashMap<String, ByteIterator>(f.size());
for (String field : f) {

代码示例来源:origin: brianfrankcooper/YCSB

if (fields == null) {
 fields = content.getNames();

代码示例来源:origin: org.apereo.cas/cas-server-support-couchbase-core

/**
 * Collect attributes from entity map.
 *
 * @param couchbaseEntity the couchbase entity
 * @param filter          the filter
 * @return the map
 */
public Map<String, Object> collectAttributesFromEntity(final JsonObject couchbaseEntity, final Predicate<String> filter) {
  return couchbaseEntity.getNames()
    .stream()
    .filter(filter)
    .map(name -> Pair.of(name, couchbaseEntity.get(name)))
    .collect(Collectors.toMap(Pair::getKey, Pair::getValue));
}

代码示例来源:origin: lagom/lagom-recipes

public CompletionStage<List<UserGreeting>> listUserGreetings() {
  return couchbaseSession.get(GreetingsRepository.HelloEventProcessor.DOC_ID)
    .thenApply(docOpt -> {
      if (docOpt.isPresent()) {
        JsonObject content = docOpt.get().content();
        return content.getNames().stream().map(
          name -> new UserGreeting(name, content.getString(name))
        ).collect(Collectors.toList());
      } else {
        return Collections.emptyList();
      }
    });
}

代码示例来源:origin: com.couchbase.client/java-client

/**
 * Create a {@link MutationState} from the serialized state.
 *
 * @param source the source state, serialized.
 * @return the created {@link MutationState}.
 */
public static MutationState from(JsonObject source) {
  try {
    MutationState state = new MutationState();
    for (String bucketName : source.getNames()) {
      JsonObject bucket = source.getObject(bucketName);
      for (String vbid : bucket.getNames()) {
        JsonArray values = bucket.getArray(vbid);
        state.addToken(new MutationToken(
          Long.parseLong(vbid),
          Long.parseLong(values.getString(1)),
          values.getLong(0),
          bucketName
        ));
      }
    }
    return state;
  } catch (Exception ex) {
    throw new IllegalStateException("Could not import MutationState from JSON.", ex);
  }
}

代码示例来源:origin: com.couchbase.client/java-client

for(String viewName: rawViews.getNames()) {
    JsonObject viewContent = rawViews.getObject(viewName);
    String map = viewContent.getString("map");
  for(String viewName : spatialViews.getNames()) {
    String map = spatialViews.getString(viewName);
    views.add(SpatialView.create(viewName, map));
final Map<Option, Long> options = new HashMap<Option, Long>();
if (opts != null) {
  for (String key : opts.getNames()) {
    options.put(Option.fromName(key), opts.getLong(key));

代码示例来源:origin: com.couchbase.client/java-client

@Override
  public JsonObject query() {
    JsonObject query = super.query();

    if (named != null && !named.isEmpty()) {
      for (String key : named.getNames()) {
        Object value = named.get(key);
        if (!key.startsWith("$")) {
          key = "$" + key;
        }
        query.put(key, value);
      }
    }
    if (positional != null && !positional.isEmpty()) {
      query.put("args", positional);
    }
    return query;
  }
}

代码示例来源:origin: com.couchbase.client/java-client

/**
 * Populate a {@link JsonObject} representation of a query with parameters, either positional or named.
 *
 *  - If params is a {@link JsonObject}, named parameters will be used (prefixing the names with '$' if not present).
 *  - If params is a {@link JsonArray}, positional parameters will be used.
 *  - If params is null or an empty json, no parameters are populated in the query object.
 *
 * Note that the {@link JsonValue} should not be mutated until {@link #n1ql()} is called since it backs the
 * creation of the query string.
 *
 * Also, the {@link Statement} is expected to contain the correct placeholders (corresponding names and number).
 *
 * @param query the query JsonObject to populated with parameters.
 * @param params the parameters.
 */
public static void populateParameters(JsonObject query, JsonValue params) {
  if (params instanceof JsonArray && !((JsonArray) params).isEmpty()) {
    query.put("args", (JsonArray) params);
  } else if (params instanceof JsonObject && !((JsonObject) params).isEmpty()) {
    JsonObject namedParams = (JsonObject) params;
    for (String key : namedParams.getNames()) {
      Object value = namedParams.get(key);
      if (key.charAt(0) != '$') {
        query.put('$' + key, value);
      } else {
        query.put(key, value);
      }
    }
  } //else do nothing, as if a simple statement
}

代码示例来源:origin: com.couchbase.client/java-client

if (fragmentsJson != null) {
      fragments = new HashMap<String, List<String>>(fragmentsJson.size());
      for (String field : fragmentsJson.getNames()) {
        List<String> fragment;
        JsonArray fragmentJson = fragmentsJson.getArray(field);
    if (fieldsJson != null) {
      fields = new HashMap<String, String>(fieldsJson.size());
      for (String f : fieldsJson.getNames()) {
        fields.put(f, String.valueOf(fieldsJson.get(f)));
if (facetsJson != null) {
  facets = new ArrayList<FacetResult>(facetsJson.size());
  for (String facetName : facetsJson.getNames()) {
    JsonObject facetJson = facetsJson.getObject(facetName);
    String field = facetJson.getString("field");
  JsonObject errorsJson = (JsonObject) errorsRaw;
  List<Exception> exceptions = new ArrayList<Exception>(errorsJson.size());
  for (String key : errorsJson.getNames()) {
    exceptions.add(new RuntimeException(key + ": " + errorsJson.get(key)));

代码示例来源:origin: com.couchbase.client/java-client

for (String field : locationsJson.getNames()) {
  JsonObject termsJson = locationsJson.getObject(field);
  for (String term : termsJson.getNames()) {
    JsonArray locsJson = termsJson.getArray(term);

相关文章