bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#32920: Patch: Add variable json-pretty-print-max-indentation-level t


From: Lars Ingebrigtsen
Subject: bug#32920: Patch: Add variable json-pretty-print-max-indentation-level to allow more flexibility when pretty-printing json
Date: Sun, 23 Jun 2019 23:25:03 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Jose Arroyo <jose.m.arroyo.se@gmail.com> 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]