From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Re: Can the json reader be a bit more lenient? Date: Sun, 4 Aug 2019 01:47:42 +0700 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="200240"; mail-complaints-to="usenet@blaine.gmane.org" Cc: "help-gnu-emacs@gnu.org" To: ndame Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Aug 03 20:49:03 2019 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1htz5R-000pup-Mb for geh-help-gnu-emacs@m.gmane.org; Sat, 03 Aug 2019 20:49:01 +0200 Original-Received: from localhost ([::1]:41346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz5Q-00074N-Jl for geh-help-gnu-emacs@m.gmane.org; Sat, 03 Aug 2019 14:49:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60373) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz4O-0005Zz-Ol for help-gnu-emacs@gnu.org; Sat, 03 Aug 2019 14:47:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz4N-0006xv-Or for help-gnu-emacs@gnu.org; Sat, 03 Aug 2019 14:47:56 -0400 Original-Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]:33832) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz4N-0006xU-HN for help-gnu-emacs@gnu.org; Sat, 03 Aug 2019 14:47:55 -0400 Original-Received: by mail-ed1-x529.google.com with SMTP id s49so40377456edb.1 for ; Sat, 03 Aug 2019 11:47:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=GEtPNhAC3lHoMfsVL/1+2vFA6PhUcIk+qbhDMaPQ92k=; b=rEK/MvIgpeDzkt7nxyovhlWuqjc6BwyFdc7Ei+o98KE6zM8GisiJRjIaBB/tamBwNG WA3JHLLaoguP4enEU22UTV3pN5CS5FDvra0tUSCezfdK5ojarefRBQsrcmRt0kalzIu7 cn/7P0YsPF7Cp4sRtwYsY/QoRihgNsIQy4hLOtkku/PGxKSQnkyv0trZXDgI3WhckskC 5If9yC279BR22PUwlOb15xKlfVapUrMThJAVuFdPSrFsK5gHMfGHMcIUxCVWXjomePE5 r8dsoktklJ9F8c3gXYUQbLJwicT0WK17gtnbObKG15uLAuKY32m4DlJwiBKsV95V2bTR GUsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=GEtPNhAC3lHoMfsVL/1+2vFA6PhUcIk+qbhDMaPQ92k=; b=odbCDMv1MckL4Ifh3nu8kSRlrL+dB9bEZxGE24TEexQWBuDm3V9QumfeDQj1dEqNx0 tnme0JkcRTZ7izHRIch5zzNYt0SmTpGh6pE59rijFwPPfs8/7A7wJZxny+BaSMWaxNNC CQZM04ImTMFpmwiWMvyXkCLPnkpLMLO/i1iLd2UlQBDen4IznP/KCQ0tWjBUrZN4Rzow D0s3c0bpY4/u4WgF630P4L8oG/9pZMYobUWh5nc5Y9FIzDsAUTrKJ6iqjuL1aBd1QP2x p3I5oXjy87i5m+V0O/m3Ou0XknPlrardQzxxZPcbqJivNwF2yG6HNPIGCyLGQx8jc/RG aHlA== X-Gm-Message-State: APjAAAUkBkaLJly1Q6l3CizMFwiRc6MFTA8ctiZ76JIaJbZ07Eb/0FLL v/YWEwOwOcM6Rs72yVuximG6WOMpwgEwkZdfSXg= X-Google-Smtp-Source: APXvYqxIsFCFVaAfbn5CKIQvHn+vjgPyTRj6Clj/7eglFHpyO5ESCncnhKYjdbrkslbki0wloX2uHQ92Do798M/eunM= X-Received: by 2002:a50:acc6:: with SMTP id x64mr128612855edc.100.1564858073625; Sat, 03 Aug 2019 11:47:53 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::529 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:121305 Archived-At: On Wed, Jul 31, 2019 at 6:52 PM ndame 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=E2=80=99s 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=E2=80=99s 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.