diff --git a/src/main/java/com/box/sdk/BoxJSONObject.java b/src/main/java/com/box/sdk/BoxJSONObject.java index 4c7d2db8a..4945be222 100644 --- a/src/main/java/com/box/sdk/BoxJSONObject.java +++ b/src/main/java/com/box/sdk/BoxJSONObject.java @@ -20,6 +20,11 @@ public abstract class BoxJSONObject { */ private JsonObject pendingChanges; + /** + * The current JSON object + */ + private JsonObject jsonObject; + /** * A map of other BoxJSONObjects which will be lazily converted to a JsonObject once getPendingChanges is called. * This allows changes to be made to a child BoxJSONObject and still have those changes reflected in the JSON @@ -181,7 +186,7 @@ void removePendingChange(String key) { } /** - * Updates this BoxJSONObject using the information in a JSON object. + * Updates this BoxJSONObject using the information in a JSON object and preserves the JSON object. * @param jsonObject the JSON object containing updated information. */ void update(JsonObject jsonObject) { @@ -192,7 +197,7 @@ void update(JsonObject jsonObject) { this.parseJSONMember(member); } - + this.jsonObject = jsonObject; this.clearPendingChanges(); } @@ -214,4 +219,13 @@ private JsonObject getPendingJSONObject() { } return this.pendingChanges; } + + /** + * Converts the JSON object into a string literal. + * @return a string representation of the JSON object. + */ + @Override + public String toString() { + return jsonObject.toString(); + } } diff --git a/src/main/java/com/box/sdk/BoxUser.java b/src/main/java/com/box/sdk/BoxUser.java index 4c4490d0b..544b5e143 100644 --- a/src/main/java/com/box/sdk/BoxUser.java +++ b/src/main/java/com/box/sdk/BoxUser.java @@ -719,6 +719,14 @@ public Info() { super(); } + /** + * Constructs an Info object by parsing information from a JSON string. + * @param json the JSON string to parse. + */ + public Info(String json) { + super(json); + } + Info(JsonObject jsonObject) { super(jsonObject); }