本文整理汇总了Java中com.eclipsesource.json.JsonValue.asString方法的典型用法代码示例。如果您正苦于以下问题:Java JsonValue.asString方法的具体用法?Java JsonValue.asString怎么用?Java JsonValue.asString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.eclipsesource.json.JsonValue
的用法示例。
在下文中一共展示了JsonValue.asString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addItem
import com.eclipsesource.json.JsonValue; //导入方法依赖的package包/类
public static void addItem(JsonObject js) {
if (js.get("tool") != null) {
addItemTool(js);
return;
}
String id = json.getString("id", null);
if (id == null)
throw new JsonException("No item id");
JItem item = new JItem(id);
JsonValue prop;
prop = js.get("texture");
if (prop != null) {
item.textureString = prop.asString();
} else {
item.textureString = id;
}
for (JsonObject.Member member : js) {
switch (member.getName()) {
case "id":
case "texture":
break;
default:
throw new JsonException("Unexpected block member \"" + member.getName() + "\"");
}
}
IDManager.register(item);
}
示例2: addItemTool
import com.eclipsesource.json.JsonValue; //导入方法依赖的package包/类
public static void addItemTool(JsonObject js) {
String id = js.getString("id", null);
if (id == null) {
throw new JsonException("No item id");
}
JItemTool item = new JItemTool(id);
JsonObject tool = js.get("tool").asObject();
addItemToolFor(tool, item);
JsonValue prop;
prop = js.get("texture");
if (prop != null) {
item.textureString = prop.asString();
} else {
item.textureString = id;
}
for (JsonObject.Member member : js) {
switch (member.getName()) {
case "id":
case "texture":
case "tool":
break;
default:
throw new JsonException("Unexpected block member \"" + member.getName() + "\"");
}
}
IDManager.register(item);
}
示例3: readJson
import com.eclipsesource.json.JsonValue; //导入方法依赖的package包/类
@Override
public void readJson(JsonValue json) {
String str = json.asString();
if (str != null)
this.s = str;
onChange();
}
示例4: addItem
import com.eclipsesource.json.JsonValue; //导入方法依赖的package包/类
public static void addItem(JsonObject json) {
if (json.get("tool") != null) {
addItemTool(json);
return;
}
String id = json.getString("id", null);
if (id == null) throw new JsonException("No item id");
JItem item = new JItem(id);
JsonValue prop;
prop = json.get("texture");
if (prop != null) {
item.textureString = prop.asString();
} else {
item.textureString = id;
}
for (JsonObject.Member member : json) {
switch (member.getName()) {
case "id":
case "texture":
break;
default:
throw new JsonException("Unexpected block member \"" + member.getName() + "\"");
}
}
IDManager.register(item);
}
示例5: readJson
import com.eclipsesource.json.JsonValue; //导入方法依赖的package包/类
@Override
public void readJson(JsonValue json) {
String str = json.asString();
if (str != null) this.s = str;
onChange();
}