typhoid / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

JsonElement.toString() output is unspecified #591

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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