2 comments

  • yairlenga 9 hours ago ago

    Most JSON serializers give you only two choices: compact machine output, or fully expanded "pretty-print" for humans. Neither is ideal when JSON needs to be consumed by both.

    I wrote a small Python module called jsonfold, post processing the output of json.dump() (and other similar serializers). It will selectively fold short lines and small containers while still keeping the JSON readable.

    It works as a lightweight wrapper for file-like objects, and it does NOT re-parse the JSON stream, so it can handle large documents with fixed memory usage and linear processing time.

    Sample output (line width, level of folding, ... can be customized):

    { "a": { "b": { "c": "abc" } }, "x": { "y": { "z": "xyz" } } }

  • bhupendraTale05 8 hours ago ago

    [dead]