Markus Armbruster <arm...@redhat.com> writes: > Eric Blake <ebl...@redhat.com> writes: > >> On 07/29/2015 03:19 AM, Markus Armbruster wrote: >>>>> Longest line is a bit over 4KiB for me. >>>>> >>>> >>>> If we break up string literals, at least use some indentation to make it >>>> obvious that multiple lines merge to a single array entry. For example >>>> (after patch 47): >>>> >>>> ... >>>> "{ 'name': ':abr', 'meta-type': 'object', " >>>> "'members': [ " >>>> "{ 'name': 'device', 'type': ':acg', 'default': null }, " >>>> "{ 'name': 'node-name', 'type': ':acg', 'default': null }, " >>>> "{ 'name': 'snapshot-file', 'type': ':acg' }, " >>>> "{ 'name': 'snapshot-node-name', 'type': ':acg', 'default': null >>>> }, " >>>> "{ 'name': 'format', 'type': ':acg', 'default': null }, " >>>> "{ 'name': 'mode', 'type': ':afo', 'default': null } ] }, " >>>> "{ 'name': ... " >>> >>> Unconventional indentation, but if it helps the reader... >> >> I'm not a stickler about the particular spacing I used, so much as >> demonstrating an idea. Pick any indentation you like; I was just >> demonstrating that some well-chosen line breaks, coupled with visual >> clues on what belongs together, can help in reading the string literal >> in the generated file. >> >> In fact, doesn't python have a way to pretty-print JSON, and then >> post-process the pretty-printed string to add C \" escaping? > > Interesting idea, definitely worth a doc search.
Module json, new in 2.6 (Oct 2008). As usual, we're a decade behind: 2.4 (Nov 2004). > Prettier output can of course be punted to a followup-patch. I guess it'll have to wait for 2.6. [...]