Issue 104 in json-simple: StringBuilder and StringBuffer values are unquoted

8 views
Skip to first unread message

json-...@googlecode.com

unread,
Feb 5, 2015, 6:21:53 AM2/5/15
to json-...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 104 by pft...@gmail.com: StringBuilder and StringBuffer values
are unquoted
https://code.google.com/p/json-simple/issues/detail?id=104

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.


Attachments:
string_builder_diff.txt 1.5 KB

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

json-...@googlecode.com

unread,
Feb 5, 2015, 6:27:55 AM2/5/15
to json-...@googlegroups.com

Comment #1 on issue 104 by pft...@gmail.com: StringBuilder and StringBuffer
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.

Attachments:
string_builder_diff_2.txt 1.2 KB
Reply all
Reply to author
Forward
0 new messages