Subject: Re: bug#32920: Patch: Add variable json-pretty-print-max-indentation-level to allow more flexibility when pretty-printing json

From: Lars Ingebrigtsen <[email-masked]>
Date: Sun, 23 Jun 2019 23:25:03 +0200

Jose Arroyo <[email-masked]> writes:

> For example, if we have the following json
> {"firstKey": {"46": "0"},"secondKey": {"46": [[[[0,0],0],0],0]},"thirdKey":
> {"46": 0}}
>
> The current json-pretty-print outputs:
> {
>   "firstKey": {
>     "46": "0"
>   },
>   "secondKey": {
>     "46": [
>       [
>         [
>           [
>             0,
>             0
>           ],
>           0
>         ],
>         0
>       ],
>       0
>     ]
>   },
>   "thirdKey": {
>     "46": 0
>   }
> }

That is, indeed, really bad pretty printing of the arrays.  But I think
the approach you take in the patch isn't ideal, either: If you have
nested hash maps, then you want to have them nicely indented and broken
up into shapes like the one above.

> Whereas my/json-flatten-object-one-level would output:
> {
>   "firstKey": {"46": "0"},
>   "secondKey": {"46": [[[[0,0],0],0],0]},
>   "thirdKey": {"46": 0}
> }

I think a better solution here would be to just handle [] arrays in a
totally different way than the current pretty-printer, and instead keep
them on one line.  Well, at least more on one line than today...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no