/** * Appends a new member to the end of this object, with the specified name and the JSON * representation of the specified <code>long</code> value. * <p> * This method <strong>does not prevent duplicate names</strong>. Calling this method with a name * that already exists in the object will append another member with the same name. In order to * replace existing members, use the method <code>set(name, value)</code> instead. However, * <strong> <em>add</em> is much faster than <em>set</em></strong> (because it does not need to * search for existing members). Therefore <em>add</em> should be preferred when constructing new * objects. * </p> * * @param name * the name of the member to add * @param value * the value of the member to add * @return the object itself, to enable method chaining */ public JsonObject add(String name, long value) { add(name, valueOf(value)); return this; }
/** * Appends a new member to the end of this object, with the specified name and the JSON * representation of the specified <code>float</code> value. * <p> * This method <strong>does not prevent duplicate names</strong>. Calling this method with a name * that already exists in the object will append another member with the same name. In order to * replace existing members, use the method <code>set(name, value)</code> instead. However, * <strong> <em>add</em> is much faster than <em>set</em></strong> (because it does not need to * search for existing members). Therefore <em>add</em> should be preferred when constructing new * objects. * </p> * * @param name * the name of the member to add * @param value * the value of the member to add * @return the object itself, to enable method chaining */ public JsonObject add(String name, float value) { add(name, valueOf(value)); return this; }
/** * Appends a new member to the end of this object, with the specified name and the JSON * representation of the specified <code>int</code> value. * <p> * This method <strong>does not prevent duplicate names</strong>. Calling this method with a name * that already exists in the object will append another member with the same name. In order to * replace existing members, use the method <code>set(name, value)</code> instead. However, * <strong> <em>add</em> is much faster than <em>set</em></strong> (because it does not need to * search for existing members). Therefore <em>add</em> should be preferred when constructing new * objects. * </p> * * @param name * the name of the member to add * @param value * the value of the member to add * @return the object itself, to enable method chaining */ public JsonObject add(String name, int value) { add(name, valueOf(value)); return this; }
/** * Appends a new member to the end of this object, with the specified name and the JSON * representation of the specified string. * <p> * This method <strong>does not prevent duplicate names</strong>. Calling this method with a name * that already exists in the object will append another member with the same name. In order to * replace existing members, use the method <code>set(name, value)</code> instead. However, * <strong> <em>add</em> is much faster than <em>set</em></strong> (because it does not need to * search for existing members). Therefore <em>add</em> should be preferred when constructing new * objects. * </p> * * @param name * the name of the member to add * @param value * the value of the member to add * @return the object itself, to enable method chaining */ public JsonObject add(String name, String value) { add(name, valueOf(value)); return this; }
/** * Appends a new member to the end of this object, with the specified name and the JSON * representation of the specified <code>boolean</code> value. * <p> * This method <strong>does not prevent duplicate names</strong>. Calling this method with a name * that already exists in the object will append another member with the same name. In order to * replace existing members, use the method <code>set(name, value)</code> instead. However, * <strong> <em>add</em> is much faster than <em>set</em></strong> (because it does not need to * search for existing members). Therefore <em>add</em> should be preferred when constructing new * objects. * </p> * * @param name * the name of the member to add * @param value * the value of the member to add * @return the object itself, to enable method chaining */ public JsonObject add(String name, boolean value) { add(name, valueOf(value)); return this; }
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; }
/** * Appends a new member to the end of this object, with the specified name and the JSON * representation of the specified <code>int</code> value. * <p> * This method <strong>does not prevent duplicate names</strong>. Calling this method with a name * that already exists in the object will append another member with the same name. In order to * replace existing members, use the method <code>set(name, value)</code> instead. However, * <strong> <em>add</em> is much faster than <em>set</em></strong> (because it does not need to * search for existing members). Therefore <em>add</em> should be preferred when constructing new * objects. * </p> * * @param name * the name of the member to add * @param value * the value of the member to add * @return the object itself, to enable method chaining */ public JsonObject add(String name, int value) { add(name, valueOf(value)); return this; }
/** * Appends a new member to the end of this object, with the specified name and the JSON * representation of the specified <code>long</code> value. * <p> * This method <strong>does not prevent duplicate names</strong>. Calling this method with a name * that already exists in the object will append another member with the same name. In order to * replace existing members, use the method <code>set(name, value)</code> instead. However, * <strong> <em>add</em> is much faster than <em>set</em></strong> (because it does not need to * search for existing members). Therefore <em>add</em> should be preferred when constructing new * objects. * </p> * * @param name * the name of the member to add * @param value * the value of the member to add * @return the object itself, to enable method chaining */ public JsonObject add(String name, long value) { add(name, valueOf(value)); return this; }
/** * Appends a new member to the end of this object, with the specified name and the JSON * representation of the specified <code>double</code> value. * <p> * This method <strong>does not prevent duplicate names</strong>. Calling this method with a name * that already exists in the object will append another member with the same name. In order to * replace existing members, use the method <code>set(name, value)</code> instead. However, * <strong> <em>add</em> is much faster than <em>set</em></strong> (because it does not need to * search for existing members). Therefore <em>add</em> should be preferred when constructing new * objects. * </p> * * @param name * the name of the member to add * @param value * the value of the member to add * @return the object itself, to enable method chaining */ public JsonObject add(String name, double value) { add(name, valueOf(value)); return this; }
/** * Appends a new member to the end of this object, with the specified name and the JSON * representation of the specified <code>boolean</code> value. * <p> * This method <strong>does not prevent duplicate names</strong>. Calling this method with a name * that already exists in the object will append another member with the same name. In order to * replace existing members, use the method <code>set(name, value)</code> instead. However, * <strong> <em>add</em> is much faster than <em>set</em></strong> (because it does not need to * search for existing members). Therefore <em>add</em> should be preferred when constructing new * objects. * </p> * * @param name * the name of the member to add * @param value * the value of the member to add * @return the object itself, to enable method chaining */ public JsonObject add(String name, boolean value) { add(name, valueOf(value)); return this; }
/** * 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 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 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; }