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

StringBuilder and StringBuffer values are unquoted #104

Open
GoogleCodeExporter opened this issue Dec 24, 2015 · 1 comment
Open

StringBuilder and StringBuffer values are unquoted #104

GoogleCodeExporter opened this issue Dec 24, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

When converting a StringBuilder or StringBuffer object to JSON the values are 
not treated as strings and and not quoted in the resulting JSON string.

  assertEquals("\"v\"", JSONValue.toJSONString(new StringBuilder("v")));
  assertEquals("\"v\"", JSONValue.toJSONString(new StringBuffer("v")));

This can be easily fixed by treating StringBuilder and StringBuffer values as 
strings.

See attached diff for the fix.

Original issue reported on code.google.com by [email protected] on 5 Feb 2015 at 11:21

Attachments:

@GoogleCodeExporter
Copy link
Author

Actually realised there is a more general fix that would take care of other 
objects that need to be converted to strings (see attached diff 
string_builder_diff_2.txt).     This would mean any object not dealt with 
explicitly would always be treated as a string value.

Original comment by [email protected] on 5 Feb 2015 at 11:27

Attachments:

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

No branches or pull requests

1 participant