/** * Returns an unmodifiable JsonObject for the specified one. This method allows to provide * read-only access to a JsonObject. * <p> * The returned JsonObject is backed by the given object and reflect changes that happen to it. * Attempts to modify the returned JsonObject result in an * <code>UnsupportedOperationException</code>. * </p> * * @param object * the JsonObject for which an unmodifiable JsonObject is to be returned * @return an unmodifiable view of the specified JsonObject */ public static JsonObject unmodifiableObject(JsonObject object) { return new JsonObject(object, true); }
/** * Returns an unmodifiable JsonObject for the specified one. This method allows to provide * read-only access to a JsonObject. * <p> * The returned JsonObject is backed by the given object and reflect changes that happen to it. * Attempts to modify the returned JsonObject result in an * <code>UnsupportedOperationException</code>. * </p> * * @param object * the JsonObject for which an unmodifiable JsonObject is to be returned * @return an unmodifiable view of the specified JsonObject */ public static JsonObject unmodifiableObject(JsonObject object) { return new JsonObject(object, true); }
public JsonObject asJson() { JsonObject json = new JsonObject(); json.add("name", name); json.add("id", uuid.toString()); return json; }
public JsonObject asJson() { JsonObject json = new JsonObject(); json.add("name", name); json.add("protocol", protocol); return json; }
/** * Gets this action performance as JSON, for transmission. * * @return The JSON. */ public JsonObject asJson() { JsonObject obj = new JsonObject(); obj.add("action", this.action.name().toLowerCase()); obj.add("value", this.value); return obj; }
/** * Gets this action performance as JSON, for * transmission. * * @return The JSON. */ public JsonValue asJson() { JsonObject obj = new JsonObject(); obj.add("action", this.action.name().toLowerCase()); obj.add("value", this.value); return obj; } }
public void afOutputConfiguration() { JsonObject app = this.fetchConfigFor(this); JsonObject config = new JsonObject(); config.add(this.afId(), app); System.out.println(config.toString(Stringify.HJSON)); }
public void afOutputConfiguration() { final JsonObject app = this.fetchConfigFor(this); final JsonObject config = new JsonObject(); config.add(this.afId(), app); System.out.println(config.toString(Stringify.HJSON)); }
private JsonObject fetchConfigFor(Object obj) { JsonObject json = new JsonObject();
private JsonObject fetchConfigFor(final Object obj) { final JsonObject json = new JsonObject();
public JsonObject asJson() { JsonObject json = new JsonObject(); json.add("max", maxPlayers); json.add("online", onlinePlayers); JsonArray sampleArray = new JsonArray(); for (ServerPingResponseSample sample : samples) { if (sample != null) { sampleArray.add(sample.asJson()); } } json.add("sample", sampleArray); return json; }
/** * Adds an item property to the chat component. * * @param item the item * @return the new hover action event */ public static HoverEvent item(Item item) { JsonObject json = new JsonObject(); json.add("id", item.getSubstance().toString().replaceAll("minecraft:", "")); json.add("Damage", item.getDamage()); json.add("Count", item.getCount()); json.add("tag", "{}"); String string = json.toString().replaceAll("\"", ""); return new HoverEvent(HoverAction.SHOW_ITEM, JsonValue.valueOf(string)); }
public JsonObject asJson() { JsonObject json = new JsonObject(); json.add("version", version.asJson()); json.add("players", players.asJson()); json.add("description", description.asJson()); if (serverIconBase64 != null) { json.add("favicon", serverIconBase64); } return json; }
JsonObject json = new JsonObject(); String scoreObjective = this.scoreObjective; if (scoreUsername != null && scoreObjective != null) { JsonObject score = new JsonObject(); score.add("name", scoreUsername); score.add("objective", scoreObjective);
JsonObject json = new JsonObject(); String scoreObjective = this.scoreObjective; if (scoreUsername != null && scoreObjective != null) { JsonObject score = new JsonObject(); score.add("name", scoreUsername); score.add("objective", scoreObjective);
private JsonObject readObject() throws IOException { read(); JsonObject object=new JsonObject(); skipWhiteSpace(); if (readIf('}')) { return object; } do { skipWhiteSpace(); String name=readName(); skipWhiteSpace(); if (!readIf(':')) { throw expected("':'"); } skipWhiteSpace(); object.add(name, readValue()); skipWhiteSpace(); } while (readIf(',')); if (!readIf('}')) { throw expected("',' or '}'"); } return object; }
private JsonObject readObject() throws IOException { read(); JsonObject object=new JsonObject(); skipWhiteSpace(); if (readIf('}')) { return object; } do { skipWhiteSpace(); String name=readName(); skipWhiteSpace(); if (!readIf(':')) { throw expected("':'"); } skipWhiteSpace(); object.add(name, readValue()); skipWhiteSpace(); } while (readIf(',')); if (!readIf('}')) { throw expected("',' or '}'"); } return object; }
private JsonObject readObject(boolean objectWithoutBraces) throws IOException { if (!objectWithoutBraces) read(); JsonObject object=new JsonObject(); skipWhiteSpace(); while (true) { if (objectWithoutBraces) { if (isEndOfText()) break; } else { if (isEndOfText()) throw error("End of input while parsing an object (did you forget a closing '}'?)"); if (readIf('}')) break; } String name=readName(); skipWhiteSpace(); if (!readIf(':')) { throw expected("':'"); } skipWhiteSpace(); object.add(name, readValue()); skipWhiteSpace(); if (readIf(',')) skipWhiteSpace(); // , is optional } return object; }
private JsonObject readObject(boolean objectWithoutBraces) throws IOException { if (!objectWithoutBraces) read(); JsonObject object=new JsonObject(); skipWhiteSpace(); while (true) { if (objectWithoutBraces) { if (isEndOfText()) break; } else { if (isEndOfText()) throw error("End of input while parsing an object (did you forget a closing '}'?)"); if (readIf('}')) break; } String name=readName(); skipWhiteSpace(); if (!readIf(':')) { throw expected("':'"); } skipWhiteSpace(); object.add(name, readValue()); skipWhiteSpace(); if (readIf(',')) skipWhiteSpace(); // , is optional } return object; }