unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Barry Margolin <barmar@alum.mit.edu>, help-gnu-emacs@gnu.org
Subject: RE: Hack for JSON sequences with trailing commas?
Date: Thu, 2 Aug 2018 17:51:35 -0700 (PDT)	[thread overview]
Message-ID: <d6515ff6-5736-4ed3-be42-27da072ce300@default> (raw)
In-Reply-To: <<barmar-81F7D5.18423702082018@reader.eternal-september.org>>

> > > JSON is a very limited subset of Javascript notation for literals. Many
> > > things that are allowed in Javascript source code are not allowed in
> > > JSON. The reason is presumably to simplify the design of JSON parsers --
> > > they don't have to deal with all possible input formats.
> >
> > Yes, but there is a difference between JSON as defined by its standard
> > and JSON as it is used in practice in many situations. The former is more
> > strict than the latter.
> >
> > Here is one description of possible differences between the strict syntax
> > of the standard and a lax syntax (one that does allow an extra, final
> > comma):
> >
> > https://docs.oracle.com/en/database/oracle/oracle-
> database/18/adjsn/conditions
> > -is-json-and-is-not-json.html#GUID-1B6CFFBE-85FE-41DD-BA14-
> DD1DE73EAB20
> 
> I think Oracle is unusual in being so permissive. I don't think the JSON
> parsers in PHP, Python, or Javascript allow as much as Oracle does.

It's only permissive if/when you want it to be. You can easily get strict behavior (i.e., per the JSON standard). IOW, you have a choice.

And what you want can depend on what you're doing. You might want to be able to store documents that are not strictly well-formed but are well-formed according to the lax syntax. But you might also want to process such stored documents in various ways, some of which accept only documents that are strictly well-formed. You can specify the behavior you want for storing and for various operations.

> I think the only common extension to JSON that was commonly allowed was
> allowing the top-level value to be something other than an object or
> array. The JSON spec was recently updated to legitimize this.

Yes, that's something different. The JSON spec is one thing. Uses of JSON data in practice are another thing. Only a subset of such uses require documents that adhere to the standard. Sometimes you can't control the kinds of documents you receive, but you want to be able to process them whether they strictly conform to the standard or not.



  parent reply	other threads:[~2018-08-03  0:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.4482.1533056121.1292.help-gnu-emacs@gnu.org>
2018-08-01  6:53 ` Hack for JSON sequences with trailing commas? Barry Margolin
2018-08-01  7:22   ` Yuri Khan
2018-08-01  9:58     ` Skip Montanaro
2018-08-01 14:40   ` Drew Adams
     [not found]   ` <mailman.4559.1533134429.1292.help-gnu-emacs@gnu.org>
2018-08-02 22:42     ` Barry Margolin
     [not found]       ` <mailman.4627.1533257510.1292.help-gnu-emacs@gnu.org>
2018-08-04 23:12         ` Barry Margolin
     [not found]     ` <<barmar-81F7D5.18423702082018@reader.eternal-september.org>
2018-08-03  0:51       ` Drew Adams [this message]
2018-07-31 16:58 Skip Montanaro

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=d6515ff6-5736-4ed3-be42-27da072ce300@default \
    --to=drew.adams@oracle.com \
    --cc=barmar@alum.mit.edu \
    --cc=help-gnu-emacs@gnu.org \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).