From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.devel Subject: Re: JSON Parsing Edge Case Date: Fri, 11 May 2018 09:45:35 +0100 Message-ID: <87bmdmbmxc.fsf@tcd.ie> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1526028263 19395 195.159.176.226 (11 May 2018 08:44:23 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 11 May 2018 08:44:23 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Noam Postavsky , Emacs developers To: "T.V Raman" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri May 11 10:44:19 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fH3f0-0004vs-Fl for ged-emacs-devel@m.gmane.org; Fri, 11 May 2018 10:44:18 +0200 Original-Received: from localhost ([::1]:37729 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fH3h7-0004Oo-F8 for ged-emacs-devel@m.gmane.org; Fri, 11 May 2018 04:46:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fH3gK-0004Og-HU for emacs-devel@gnu.org; Fri, 11 May 2018 04:45:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fH3gJ-0000Zk-J6 for emacs-devel@gnu.org; Fri, 11 May 2018 04:45:40 -0400 Original-Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:36331) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fH3gJ-0000VP-C7 for emacs-devel@gnu.org; Fri, 11 May 2018 04:45:39 -0400 Original-Received: by mail-wm0-x232.google.com with SMTP id n10-v6so1752886wmc.1 for ; Fri, 11 May 2018 01:45:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:mail-followup-to:date:in-reply-to :message-id:user-agent:mime-version; bh=61DKcaiKEi/gSBeU9Yc7YLphhxCPafftkFazPN9PEiY=; b=0MRnkFK3e/BYQBhKHSI68RoRCY139ReyVLIvRCheVjxVKFGx8mANrGhGz8SfAQ3MQ7 hjaKfFfhy6j3XEi8tudWp4NDypggYWMO1TZ3Z77Y4YNfLYRAPPTcJfs4BQPw2LCY++Bl 9i1PvoOy3cxDoNsc568li0aSG7Ol9JNwFPGN1Oip8XjIWDP98UaKgCufXGuYrhV3dZCR 8L5vVH5AfKLjwtWrfQFJjfsYEgFFgGqeQx82kzf1IIqyTWnHvyfF/w3i0MHDghAW2jEC MegEE90ZAw/CheF3enVqyLs+zbOBsMsX7lOPtnAN9jwBJwU38BXzTyEdU4Qz9Yp9SrUA HiDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:mail-followup-to :date:in-reply-to:message-id:user-agent:mime-version; bh=61DKcaiKEi/gSBeU9Yc7YLphhxCPafftkFazPN9PEiY=; b=cj/1DZlosa25Xyj+N7c/sQIWMU42Q2ijK0awUSt4ILBDB1zfrP6cE7Vc0iGPo1Yum2 xvAhQ90Al4UIeapxzHBZjcwyzJC/fzlY9zJRdjaM8YLF0f4NQjNvL037ccoydv+7je2l GqVdW2DHRPUSLxIs221q60YwH2gEmNIZlhduRBAV5+B44OEGEOfU39ddt/BtnAdT4/zL r2MT7Ymb87+D/S+03RC6PDpkSAM9NskEygtysLY9LqEDuZSDBK7NOFAx4BVlfBM0iEYV XeFexnY0eevT2Uppkq945ij8UtZkBFb1lUjjYETkzwCgwPjuu08ygrCd/laHfdOB4a3d 3OVw== X-Gm-Message-State: ALKqPwfURxWJ3lyMLBOX7pJk5MmDhv+PWZ7fzqrnFh46oqCIvDdSloj9 xk4zlbUlnLzvoEBZ5o17+ZFMPQ== X-Google-Smtp-Source: AB8JxZqOrZBdGosQrLl/t8DcyKj/+OpuMx01H3qqORQT1XOfd4kPy02Q6574j7bFhd9+fBeaJg+JBw== X-Received: by 2002:a50:cccb:: with SMTP id b11-v6mr6493879edj.98.1526028337318; Fri, 11 May 2018 01:45:37 -0700 (PDT) Original-Received: from localhost ([2a02:8084:4f41:8c80:9c34:da08:a010:edfc]) by smtp.gmail.com with ESMTPSA id w9-v6sm1590470edb.38.2018.05.11.01.45.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 May 2018 01:45:36 -0700 (PDT) Mail-Followup-To: "T.V Raman" , Noam Postavsky , Emacs developers In-Reply-To: (T.V Raman's message of "Thu, 10 May 2018 19:30:28 -0700") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::232 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:225225 Archived-At: "T.V Raman" writes: > Noam Postavsky writes: > > I meant json-read-string --apologies. json-parse-buffer needs the > underlying emacs to be compiled with the json C module. >> On 10 May 2018 at 19:48, T.V Raman wrote: >>> The following happens with both json-read -- the elisp implementation >>> as well as json-parse-string implemented in C -- >>> >>> Try this json fragment -- by typing it into an empty buffer: >>> >>> {"quote": "1"} >>> >>> The above is a json dict with one key -- "quote" -- with value 1. >>> >>> Parsing this into an emacs alist -- either with (json-read) or >>> (json-parse-buffer) >>> yields the following lisp structure -- >>> >>> ('. "1") >> >> With json-read, and (json-read-from-string "{\"quote\": \"1\"}"), I get >> >> ((quote . "1")) >> >> json-parse-string and json-parse-buffer don't seem to exist for me >> (using the latest master branch). >> FWIW, after emacs -Q and (require 'json), the following four forms all evaluate to ((quote . "1")) on my end: (with-temp-buffer (insert "{\"quote\": \"1\"}") (goto-char (point-min)) (json-read)) (with-temp-buffer (insert "{\"quote\": \"1\"}") (goto-char (point-min)) (json-parse-buffer :object-type 'alist)) (json-read-from-string "{\"quote\": \"1\"}") (json-parse-string "{\"quote\": \"1\"}" :object-type 'alist) AFAICT the json.el function json-read-string is for reading a single JSON string at point, not a whole object. -- Basil In GNU Emacs 27.0.50 (build 20, x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of 2018-05-10 built on thunk Repository revision: 766b057e41df7316808ec7658836fda75facda75 Windowing system distributor 'The X.Org Foundation', version 11.0.11906000 System Description: Debian GNU/Linux buster/sid Configured using: 'configure 'CC=ccache gcc' 'CFLAGS=-march=native -O2 -pipe' --config-cache --prefix=/home/blc/.local --with-mailutils --with-x-toolkit=lucid --with-modules --with-file-notification=yes --with-x' Configured features: XAW3D XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS LUCID X11 MODULES THREADS LIBSYSTEMD JSON LCMS2