I'm using jsoncpp to read and write json files.
For writing, I use the StyledWriter, which writes the json in a human readable fashion.
Currently, I'm trying to write an array of ints into a json file. The documentation describes the following rules for writing an array value:
- if empty then print [] without indent and line break
- if the array contains no object value, empty array or some other value types, and all the values fit on one lines, then print the array on a single line.
- otherwise, if the values do not fit on one line, or the array contains object or non empty array, then print one value per line.
Since the array I'm trying to write is too big for one line, according to the rules above, the writer prints it one value per line, which makes my json ugly and less readable. I would prefer it to write the whole array in one line or in several lines, with several values per line.
I'm aware of the fact that jasoncpp is opensource and thus I can change the writer to do what I want, but I'm wondering if there's a different way to do it. Maybe using both FastWriter (which creates a one-line-json) and StyledWriter?