/** * Merge in another JSON object. * <p> * This is the equivalent of putting all the entries of the other JSON object into this object. This is not a deep * merge, entries containing (sub) JSON objects will be replaced entirely. * @param other the other JSON object * @return a reference to this, so the API can be used fluently */ public JsonObject mergeIn(JsonObject other) { return mergeIn(other, false); }
public JsonObject toJson() { JsonObject json = new JsonObject(); json.put("weight", weight); json.put("dependency", dependency); json.put("exclusive", exclusive); return json; }
@Override public void afterConfigParsed(JsonObject config) { config.put("time", time); } };
/** * Encode the JSON array to a string * * @return the string encoding */ public String encode() { return Json.encode(list); }
@Test public void testNullInstantDecoding() { Pojo original = new Pojo(); Pojo decoded = Json.decodeValue("{\"instant\":null}", Pojo.class); assertEquals(original.instant, decoded.instant); }
/** * Encode this JSON object a a string, with whitespace to make the object easier to read by a human, or other * sentient organism. * * @return the pretty string encoding. */ public String encodePrettily() { return Json.encodePrettily(map); }
@Override public int hashCode() { int result = (enabled ? 1 : 0); result = 31 * result + (json != null ? json.hashCode() : 0); return result; }
/** * Encode this JSON object as buffer. * * @return the buffer encoding. */ public Buffer toBuffer() { return Json.encodeToBuffer(map); }
/** * Create an instance from a Buffer of JSON. * * @param buf the buffer of JSON. */ public JsonArray(Buffer buf) { fromBuffer(buf); }
/** * Create an instance from a string of JSON * * @param json the string of JSON */ public JsonObject(String json) { fromJson(json); }
/** * Create an instance from a buffer. * * @param buf the buffer to create the instance from. */ public JsonObject(Buffer buf) { fromBuffer(buf); }
/** * Create an instance from a String of JSON * * @param json the string of JSON */ public JsonArray(String json) { fromJson(json); }
@Override public void afterConfigParsed(JsonObject config) { config.put("time", time); } };
/** * Merge in another JSON object. * A deep merge (recursive) matches (sub) JSON objects in the existing tree and replaces all * matching entries. JsonArrays are treated like any other entry, i.e. replaced entirely. * @param other the other JSON object * @param deep if true, a deep merge is performed * @return a reference to this, so the API can be used fluently */ public JsonObject mergeIn(JsonObject other, boolean deep) { return mergeIn(other, deep ? Integer.MAX_VALUE : 1); }
/** * Encode this JSON object as a string. * * @return the string encoding. */ public String encode() { return Json.encode(map); }
@Test public void testNullBytesDecoding() { Pojo original = new Pojo(); Pojo decoded = Json.decodeValue("{\"bytes\":null}", Pojo.class); assertEquals(original.bytes, decoded.bytes); }
/** * Encode the JSON array prettily as a string * * @return the string encoding */ public String encodePrettily() { return Json.encodePrettily(list); }
/** * Encode this JSON object as buffer. * * @return the buffer encoding. */ public Buffer toBuffer() { return Json.encodeToBuffer(list); }