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

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

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

JsonObject.fromJson介绍

[英]Static method to create a JsonObject from a JSON String. The string is expected to be a valid JSON object representation (eg. starting with a '{').
[中]从JSON字符串创建JsonObject的静态方法。该字符串应为有效的JSON对象表示形式(例如,以“{”)开头)。

代码示例

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

/**
 * Inserts or overwrites a {@link JsonDocument}.
 *
 * @param documentId the unique ID of the document
 * @param json       the JSON String representing the document to store
 * @return the newly created or overwritten {@link JsonDocument}
 * @see Bucket#upsert(Document)
 */
public JsonDocument upsert(String documentId, String json) {
  return this.bucket.upsert(JsonDocument.create(documentId, JsonObject.fromJson(json)));
}

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

/**
 * Inserts a {@link JsonDocument} if it does not exist already.
 *
 * @param documentId the unique ID of the document
 * @param json       the JSON String representing the document to store
 * @return the newly created {@link JsonDocument}
 * @see Bucket#insert(Document)
 */
public JsonDocument insert(String documentId, String json) {
  return this.bucket.insert(JsonDocument.create(documentId, JsonObject.fromJson(json)));
}

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

/**
 * Replaces a {@link JsonDocument} if it does already exist.
 *
 * @param documentId the unique ID of the document
 * @param json       the JSON String representing the document to replace
 * @return the replaced {@link Document}
 * @see Bucket#replace(Document)
 */
public JsonDocument replace(String documentId, String json) {
  return this.bucket.replace(JsonDocument.create(documentId, JsonObject.fromJson(json)));
}

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

/**
 * Appends a {@link JsonDocument}'s content to an existing one.
 *
 * @param documentId the unique ID of the document
 * @param json       the JSON String representing the document to append
 * @return the updated {@link Document}
 * @see Bucket#append(Document)
 */
public JsonDocument append(String documentId, String json) {
  this.bucket.append(JsonDocument.create(documentId, JsonObject.fromJson(json)));
  return this.get(documentId);
}

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

/**
 * Prepends a {@link JsonDocument}'s content to an existing one.
 *
 * @param documentId the unique ID of the document
 * @param json       the JSON String representing the document to prepend
 * @return the updated {@link Document}
 * @see Bucket#prepend(Document)
 */
public JsonDocument prepend(String documentId, String json) {
  this.bucket.prepend(JsonDocument.create(documentId, JsonObject.fromJson(json)));
  return this.get(documentId);
}

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

@Override
  public JsonObject call(String stringResponse) {
    return JsonObject.fromJson(stringResponse);
  }
});

代码示例来源: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(String source) {
  return from(JsonObject.fromJson(source));
}

代码示例来源:origin: lordofthejars/nosql-unit

public static Map<String, Document> getDocuments(final InputStream dataScript) {
  try {
    final JsonObject jsonObject = JsonObject.fromJson(IOUtils.readFullStream(dataScript));
    final JsonArray data = jsonObject.getArray("data");
    return StreamSupport.stream(data.spliterator(), false)
        .map(o -> (JsonObject) o)
        .collect(Collectors.toMap(o -> o.getString("key"),
            o -> new Document(o.getObject("document"), o.getInt("expirationSecs"))));
  } catch (IOException e) {
    throw new IllegalStateException(e);
  }
}

相关文章