On Fri, 19 Aug 2022 at 10:07, Grant Edwards <grant.b.edwa...@gmail.com> wrote:
>
> On 2022-08-18, Chris Angelico <ros...@gmail.com> wrote:
> > On Fri, 19 Aug 2022 at 05:05, Grant Edwards <grant.b.edwa...@gmail.com> 
> > wrote:
> >> On 2022-08-18, Chris Angelico <ros...@gmail.com> wrote:
> >>
> >> > It's one of the frustrations with JSON, since that format doesn't
> >> > allow the trailing comma :)
> >>
> >> Yep, that's a constant, low-level pain for all the C code I deal with
> >> which generates JSON. You'd think after 10+ years of maintaining code
> >> that outputs JSON, I wouldn't trip over that any longer...
> >
> > With some JSON files, I just cheat and define a shim at the end of arrays...
> >
> > https://raw.githubusercontent.com/Rosuav/MustardMine/master/template.json
>
> That's OK if it's strictly internal. Almost all of the JSON data I
> work with is part of published APIs — many of which are defined by
> industry consortiums or corporate-wide "standards".
>

That's an export/import format that I defined, so I mandated (a) that
there's an empty-string key as a signature (on import, it can be
anywhere, but on export, it's that final shim), and (b) all arrays are
allowed to have an empty string at the end, which is ignored on
import. Saves so much trouble.

That particular export format is actually designed as a git-managed
config file as well, which is why the line breaks are done the way
they are (anything on a single line is intended to be added/removed as
a single unit), which is why I definitely don't want the "add a comma
to the previous line" deltas.

"Strictly internal" is a subset of "protocols/standards that you are
in control of". :)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to