all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Jose Arroyo <jose.m.arroyo.se@gmail.com>
Cc: 32920@debbugs.gnu.org
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	[thread overview]
Message-ID: <m3ef3k0zbk.fsf@gnus.org> (raw)
In-Reply-To: <CANg9NwXwpbaBoVh_sQf7-QG87e3SUGBhBbt0Q4ux4CGABjcEHA@mail.gmail.com> (Jose Arroyo's message of "Wed, 3 Oct 2018 17:08:47 +0200")

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	other threads:[~2019-06-23 21:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-03 15:08 bug#32920: Patch: Add variable json-pretty-print-max-indentation-level to allow more flexibility when pretty-printing json Jose Arroyo
2019-06-23 21:25 ` Lars Ingebrigtsen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3ef3k0zbk.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=32920@debbugs.gnu.org \
    --cc=jose.m.arroyo.se@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.