Opened 10 years ago
Closed 9 years ago
#7180 closed Bugs (fixed)
Property Tree: json_write() pretty = false option not fully respected for arrays
Reported by: | Owned by: | Sebastian Redl | |
---|---|---|---|
Milestone: | To Be Determined | Component: | property_tree |
Version: | Boost Development Trunk | Severity: | Problem |
Keywords: | property_tree json_write pretty indent | Cc: | n.sakisaka@… |
Description
When outputting an array with "pretty" set to false, indentation is output blindly before the closing brace. This has the potential to waste a lot of space in certain usage scenarios... like my own :)
Example:
["1","2" ]
Expected:
["1","2"]
Patch:
diff -dur boost.old/property_tree/detail/json_parser_write.hpp boost.new/property_tree/detail/json_parser_write.hpp --- boost.old/property_tree/detail/json_parser_write.hpp 2012-07-26 19:42:10.000000000 -0700 +++ boost.new/property_tree/detail/json_parser_write.hpp 2012-07-26 19:43:34.000000000 -0700 @@ -93,7 +93,8 @@ stream << Ch(','); if (pretty) stream << Ch('\n'); } - stream << Str(4 * indent, Ch(' ')) << Ch(']'); + if (pretty) stream << Str(4 * indent, Ch(' ')); + stream << Ch(']'); } else
Attachments (1)
Change History (5)
by , 10 years ago
Attachment: | jsonPrettyPrint.patch added |
---|
comment:2 by , 10 years ago
Cc: | added |
---|
comment:4 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Merged to master in 85f8d8866ccf.
Note:
See TracTickets
for help on using tickets.
Proposed patch