GNU bug report logs -
#32920
Patch: Add variable json-pretty-print-max-indentation-level to allow more flexibility when pretty-printing json
Previous Next
Full log
View this message in rfc822 format
Jose Arroyo <jose.m.arroyo.se <at> 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
This bug report was last modified 5 years and 358 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.