Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override toString() in Info classes to encode them back to JSON #52

Open
gcurtis opened this issue Jan 15, 2015 · 2 comments
Open

Override toString() in Info classes to encode them back to JSON #52

gcurtis opened this issue Jan 15, 2015 · 2 comments
Labels
enhancement Added to issues that describes enhancements
Milestone

Comments

@gcurtis
Copy link
Contributor

gcurtis commented Jan 15, 2015

Calling toString() on an Info object should return the full JSON representation of the object, including any changes made locally.

This feature makes it easier for applications to cache and store data returned from the API.

@gcurtis gcurtis added the enhancement Added to issues that describes enhancements label Jan 15, 2015
@tarrencev tarrencev added this to the Basics milestone Jun 21, 2016
@PreciselyAlyss
Copy link
Contributor

Appears to have been added by PR#461

@mattwiller mattwiller reopened this May 21, 2019
richiehowelll added a commit to richiehowelll/box-java-sdk that referenced this issue Aug 12, 2020
Introduced a JsonObject field that will preserve the current JSON object. This field is set in BoxJSONObject.update. BoxJSONObject.toString is overriden to convert this object to a string literal.

Closes box#52.
richiehowelll added a commit to richiehowelll/box-java-sdk that referenced this issue Aug 12, 2020
Following the Box coding conventions and using this keyword when referencing field.

Closes box#52.
@antusus
Copy link
Contributor

antusus commented Jan 25, 2022

I do not think that toString method should return Json object representation with all the changes. This method is used mostly for debugging/logging so it should be fast . What is required here does not look like it fits into toString specification.

All Info objects have to methods:

  • com.box.sdk.BoxJSONObject#getPendingChanges - that returns String representation of the Json with all the pending changes
  • com.box.sdk.BoxJSONObject#getPendingChangesAsJsonObject - that returns JsonObject with all the pending changes
    However those will return null if there are no pending changes.
    If we create a new method to return Json representation of current state of the Info object (as String or JsonObject) to cache it what would be the use case?
    Some application gets the response from SDK, modifies it, gets Json and cache it but what then? If it would get the object from cache and create the Info object from it the information on pending changes are lost.
    The best approach is to use com.box.sdk.BoxJSONObject#getJson which is exposed to all Info objects. If you use this Json representation to cache response and the use it to create Info object you are not loosing any information. But you have any pending changes you have to sent them via SDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Added to issues that describes enhancements
Projects
None yet
Development

No branches or pull requests

5 participants