Re: New JSON parser

From: Date: Thu, 13 Mar 2014 23:37:54 +0000
Subject: Re: New JSON parser
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Hi,

On Thu, Mar 13, 2014 at 11:52 PM, Andrea Faulds <[email protected]> wrote:
>
> On 13 Mar 2014, at 22:37, Marco Schuster <[email protected]> wrote:
>
> At least for the decoding part, it might be worth to look at the
> "Improving JSON" proposal (http://bolinfest.com/essays/json.html).
> tl;dr: support trailing or automatic line-end commas, //-style
> comments and keys not wrapped in "s, basically extend JSON syntax to
> ES5.
>
> I think it would be really cool if the new parser could (maybe with a
> option "JSON_NO_STRICT_PARSING") implement these enhancements to ease
> hand-writing of JSON files.
>
>
> Please, I urge you *not* to implement anything except the pure JSON
> standard. One of JSON’s great strengths is that there is only a single,
> canonical JSON standard. Implementing other standards would be damaging to
> interoperability.
Nothing is set in stone, and evolution should be allowed, especially
where it makes sense (trailing comma!). Also, that's why I suggested a
"relaxed parsing" flag. This way, people knowing the differences can
use what suits them best. (Also, IIRC there already exist polyfills to
implement this syntax).

> If people want nice config files, they can use PHP ;)
Sure, but it's a bit uncool to keep the same stuff in two places - I'm
thinking of a translation support for an app I write which supports
both AJAX/template-based client rendering and a more basic,
server-rendered version.

Currently, I have the stuff in a PHP array which generates a JSON file
with the translation upon manual rebuild. Alone the "support trailing
comma" function (to ease working with version control) would give me
the option of doing *everything* in JSON without manual rebuilds etc.

Marco


Thread (29 messages)

« previous php.internals (#73138) next »