YuliaFilippova / json-simple

Automatically exported from code.google.com/p/json-simple
Apache License 2.0
0 stars 0 forks source link

StringBuilder and StringBuffer values are unquoted #104

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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 pft...@gmail.com on 5 Feb 2015 at 11:21

Attachments:

GoogleCodeExporter commented 8 years ago
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 pft...@gmail.com on 5 Feb 2015 at 11:27

Attachments: