本文整理汇总了Java中javax.json.JsonObject.entrySet方法的典型用法代码示例。如果您正苦于以下问题:Java JsonObject.entrySet方法的具体用法?Java JsonObject.entrySet怎么用?Java JsonObject.entrySet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.json.JsonObject
的用法示例。
在下文中一共展示了JsonObject.entrySet方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convert
import javax.json.JsonObject; //导入方法依赖的package包/类
private void convert(JsonObject json) {
int i =0;
builder.append("Json.createObjectBuilder()\n");
for (Map.Entry<String, JsonValue> entry : json.entrySet()) {
builder.append(spaces() + indent() + ".add(");
String key = entry.getKey();
JsonValue value = entry.getValue();
builder.append('"');
builder.append(key);
builder.append('"');
builder.append(", ");
builder.append(new JsonConversion(indent + INDENT_INCREMENT).execute(value));
builder.append(")");
if(i++ != json.size() -1 ){
builder.append("\n");
}
}
}
示例2: toJavaMap
import javax.json.JsonObject; //导入方法依赖的package包/类
/**
* Converts a {@link JsonObject} to a map from names to objects returned by {@link #toJavaObject}.
* The returned map is a mutable copy that will never have null keys but may have null values.
*/
public static Map<String, Object> toJavaMap(JsonObject object) {
Map<String, Object> map = new LinkedHashMap<>();
for (Entry<String, JsonValue> e : object.entrySet()) {
map.put(e.getKey(), toJavaObject(e.getValue()));
}
return map;
}
示例3: save
import javax.json.JsonObject; //导入方法依赖的package包/类
public JsonObject save(JsonObject input, String href, String date) {
String id = href.substring(href.lastIndexOf('/') +1);
JsonObjectBuilder builder = Json.createObjectBuilder();
builder.add("id", id);
builder.add("date", date);
JsonObject jsonLink = Json.createObjectBuilder()
.add("rel", Json.createArrayBuilder().add("self").build())
.add("href", href)
.build();
builder.add("links", jsonLink);
for (Map.Entry<String, JsonValue> entry : input.entrySet()) {
builder.add(entry.getKey(), entry.getValue());
}
JsonObject storedObject = builder.build();
exampleStore.put(id, storedObject);
return storedObject;
}
示例4: mergeProperties
import javax.json.JsonObject; //导入方法依赖的package包/类
public void mergeProperties(final String properties) {
if (StringUtils.isEmpty(properties)) {
return;
}
if (StringUtils.isEmpty(getProperties())) {
setProperties(properties);
return;
}
final JsonReaderFactory fact = Json.createReaderFactory(null);
final JsonReader r1 = fact.createReader(new StringReader(getProperties()));
final JsonObjectBuilder jbf = Json.createObjectBuilder(r1.readObject());
final JsonReader r2 = fact.createReader(new StringReader(getProperties()));
final JsonObject obj2 = r2.readObject();
for (Entry<String, JsonValue> jv : obj2.entrySet()) {
jbf.add(jv.getKey(), jv.getValue());
}
setProperties(jbf.build().toString());
}
示例5: toBuilder
import javax.json.JsonObject; //导入方法依赖的package包/类
/** Converts a {@link JsonObject} to a {@JsonObjectBuilder}. */
public static JsonObjectBuilder toBuilder(JsonObject object) {
JsonObjectBuilder builder = Json.createObjectBuilder();
for (Entry<String, JsonValue> e : object.entrySet()) {
builder.add(e.getKey(), e.getValue());
}
return builder;
}