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

JsonElement.toString() output is unspecified #591

Closed
GoogleCodeExporter opened this issue Mar 19, 2015 · 0 comments · Fixed by #2659
Closed

JsonElement.toString() output is unspecified #591

GoogleCodeExporter opened this issue Mar 19, 2015 · 0 comments · Fixed by #2659

Comments

@GoogleCodeExporter
Copy link

JsonElement.toString() Javadoc:

  /**
   * Returns a String representation of this element.
   */

The actual format of JsonElement.toString() is unspecified, but some 
applications would break if the output format were changed to something that 
isn't a valid JSON representation of that object.

Suggested fix:

To me it seems reasonable to expect toString() to produce valid JSON, not just 
some arbitrary programmer-friendly string representation.

The toString() method should state that the return value is a valid JSON 
representation of the object, and that details such as indentation are left 
unspecified. 

Subclasses like JsonArray and JsonObject should override toString() just to 
provide improved documentation with example return values.

Original issue reported on code.google.com by hussdl on 22 Aug 2014 at 10:09

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants