Skip to content

JsonElement.toString() output is unspecified #591

Closed

Description

@GoogleCodeExporter
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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions