From: Yuri Khan <yuri.v.khan@gmail.com>
To: ndame <emacsuser@freemail.hu>
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Re: Can the json reader be a bit more lenient?
Date: Sun, 4 Aug 2019 01:47:42 +0700 [thread overview]
Message-ID: <CAP_d_8X33K+i6TOCk7ZiyV=fSm1h9GQ6e-xVQHWs9qMJt1TLuA@mail.gmail.com> (raw)
In-Reply-To: <AxvIkQ.ehfYo24vcBXB.C7wgqAJ4FGqa5rtCEF@freemail.hu>
On Wed, Jul 31, 2019 at 6:52 PM ndame <emacsuser@freemail.hu> wrote:
>
> Lately I've been using emacs for some text data processing, and the
> input is json sometimes. The problem is the json often comes like
> this:
>
> [{'time1: '8:00', 'time2': '13:00', ...
That’s a bug in the program generating such input.
> and the emacs reader chokes on it saying
>
> doesn't start with "!
As it well should.
> Now I know the json standard says attribute names should be double quoted,
> but can it be somehow persuaded to accept single quotes instead?
The ECMA-404 specification explicitly discourages this:
A conforming processor of JSON texts should not accept any inputs
that are not conforming JSON text.
> It would be great to have an option for this when I know the data is
> correct, only it uses single quotes instead of doubles.
IMO it’s a bad idea. If a program says it produces JSON, it should
produce well-formed JSON, with the correct quotes. We already have a
precedent of parsers forgiving small spec violations; HTML. It grew to
become a monster.
If you want to parse documents that are almost JSON but use the wrong
quote character, use a YAML parser. YAML is a superset of JSON with a
lot of syntax sugar.
prev parent reply other threads:[~2019-08-03 18:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-31 11:52 Can the json reader be a bit more lenient? ndame
2019-08-03 16:14 ` Alex Kost
2019-08-03 18:47 ` Yuri Khan [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='CAP_d_8X33K+i6TOCk7ZiyV=fSm1h9GQ6e-xVQHWs9qMJt1TLuA@mail.gmail.com' \
--to=yuri.v.khan@gmail.com \
--cc=emacsuser@freemail.hu \
--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.
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.