/** * Returns the <code>String</code> value of the member with the specified name in this object. If * this object does not contain a member with this name, the given default value is returned. If * this object contains multiple members with the given name, the last one is picked. If this * member's value does not represent a JSON string, an exception is thrown. * * @param name * the name of the member whose value is to be returned * @param defaultValue * the value to be returned if the requested member is missing * @return the value of the last member with the specified name, or the given default value if * this object does not contain a member with that name */ public String getString(String name, String defaultValue) { JsonValue value=get(name); return value!=null ? value.asString() : defaultValue; }
/** * Returns the <code>String</code> value of the member with the specified name in this object. If * this object does not contain a member with this name, the given default value is returned. If * this object contains multiple members with the given name, the last one is picked. If this * member's value does not represent a JSON string, an exception is thrown. * * @param name * the name of the member whose value is to be returned * @param defaultValue * the value to be returned if the requested member is missing * @return the value of the last member with the specified name, or the given default value if * this object does not contain a member with that name */ public String getString(String name, String defaultValue) { JsonValue value=get(name); return value!=null ? value.asString() : defaultValue; }
private boolean equals(String key, JsonObject conditions, String value) { return !conditions.names().contains(key) || value.equalsIgnoreCase(conditions.get(key).asString()); }
/** * Parses a click event from the given JSON. * * @param json The JSON. * @return The click event. */ public static HoverEvent fromJson(JsonValue json) { return new HoverEvent(HoverAction.valueOf(json.asObject().get("action").asString().toUpperCase()), json.asObject().get("value")); }
break; case STRING: writeString(value.asString(), tw, level, separator); break; default:
case STRING: tw.write('"'); tw.write(escapeString(value.asString())); tw.write('"'); break;
break; case STRING: writeString(value.asString(), tw, level, separator); break; default:
case STRING: tw.write('"'); tw.write(escapeString(value.asString())); tw.write('"'); break;
Object convertJsonToJava(final JsonValue value) throws PersistentStoreException { if (null == value) { return null; } else if (value.isString()) { return value.asString(); } else if (value.isNumber()) { return value.asDouble(); } else if (value.isBoolean()) { return value.asBoolean(); } else if (value.isArray()) { final List<Object> list = new ArrayList<>(); for (final JsonValue av : value.asArray()) { final Object o = this.convertJsonToJava(av); list.add(o); } return list; } else if (value.isObject()) { final Map<String, Object> map = new HashMap<>(); for (final String k : value.asObject().names()) { final JsonValue jv = value.asObject().get(k); final Object v = this.convertJsonToJava(jv); map.put(k, v); } return map; } else { throw new PersistentStoreException("Unknown JSON type.", null); } }
return null; } else if (value.isString()) { final T t = this.af.createDatatype(itemType, value.asString()); return t; } else if (value.isNumber()) {
JsonValue text = json.get("text"); if (text != null) { cc.setText(text.asString()); cc.setTranslate(translate.asString()); JsonValue el = array.get(i); if (el.isString() || el.isNumber() || el.isBoolean()) cc.addWith(el.asString()); else if (el.isObject()) cc.addWith(fromJson(el.asObject())); if (score != null) { JsonObject scoreArray = score.asObject(); cc.setScoreUsername(scoreArray.get("name").asString()); cc.setScoreObjective(scoreArray.get("objective").asString()); cc.setSelector(selector.asString()); JsonValue el = array.get(i); if (el.isString() || el.isNumber() || el.isBoolean()) cc.addExtra(el.asString()); else if (el.isObject()) cc.addExtra(fromJson(el.asObject())); cc.setColor(ChatColor.valueOf(color.asString().toUpperCase())); cc.setInsertion(insertion.asString());