jsonpp-rs icon indicating copy to clipboard operation
jsonpp-rs copied to clipboard

Option to print comma at the beginning of the line

Open vbrandl opened this issue 7 years ago • 1 comments

It would be cool to have an option for the formatter to print the comma at the beginning of the line. So instead of

{
  "key1": "value1",
  "key2": "value2"
}

it should print

{
  "key1": "value1"
  , "key2": "value2"
}

This would help when the file is version controlled because adding a new value in the first case would cause a 2 line diff while adding a value in the second case, would only cause a single line diff:

{
  "key1": "value1",
  "key2": "value2",
  "key3": "value3"
}

vs.

{
  "key1": "value1"
  , "key2": "value2"
  , "key3": "value3"
}

This is inspired by the format elm decided to use. Actually for better formatting, having the opening bracet and the first key/value pair in the same line would be nice to:

{ "key1": "value1"
, "key2": "value2"
}

You could implement a format optimized for version controll while still be human readable

vbrandl avatar Jun 09 '18 09:06 vbrandl

Sorry for the long response delay. This notification must have slipped through.

I'd be willing to accept a pr for this!

flo-l avatar Feb 26 '20 08:02 flo-l