From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Newsgroups: gmane.emacs.bugs Subject: bug#21798: 25.0.50; [PATCH] Add support for retrieving paths to JSON elements Date: Mon, 02 Nov 2015 00:27:46 +0100 Message-ID: <1446420466.13180.0@smtp.gmail.com> References: <1446281162.2607.0@smtp.gmail.com> <5634CEE7.3070200@yandex.ru> <1446407553.4906.0@smtp.gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=-uGcAHqT79X22IzxXbJYF" X-Trace: ger.gmane.org 1446420501 9013 80.91.229.3 (1 Nov 2015 23:28:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 1 Nov 2015 23:28:21 +0000 (UTC) Cc: 21798@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Nov 02 00:28:11 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Zt22k-0003H2-33 for geb-bug-gnu-emacs@m.gmane.org; Mon, 02 Nov 2015 00:28:10 +0100 Original-Received: from localhost ([::1]:39283 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zt22j-00040c-9U for geb-bug-gnu-emacs@m.gmane.org; Sun, 01 Nov 2015 18:28:09 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42778) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zt22f-00040X-NB for bug-gnu-emacs@gnu.org; Sun, 01 Nov 2015 18:28:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zt22c-00022x-Fa for bug-gnu-emacs@gnu.org; Sun, 01 Nov 2015 18:28:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:57502) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zt22c-00022t-Bq for bug-gnu-emacs@gnu.org; Sun, 01 Nov 2015 18:28:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Zt22c-0001H7-3w for bug-gnu-emacs@gnu.org; Sun, 01 Nov 2015 18:28:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 01 Nov 2015 23:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21798 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 21798-submit@debbugs.gnu.org id=B21798.14464204724884 (code B ref 21798); Sun, 01 Nov 2015 23:28:02 +0000 Original-Received: (at 21798) by debbugs.gnu.org; 1 Nov 2015 23:27:52 +0000 Original-Received: from localhost ([127.0.0.1]:48210 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zt22S-0001Gh-24 for submit@debbugs.gnu.org; Sun, 01 Nov 2015 18:27:52 -0500 Original-Received: from mail-lb0-f170.google.com ([209.85.217.170]:33937) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zt22P-0001GY-Dc for 21798@debbugs.gnu.org; Sun, 01 Nov 2015 18:27:50 -0500 Original-Received: by lbbwb3 with SMTP id wb3so77298883lbb.1 for <21798@debbugs.gnu.org>; Sun, 01 Nov 2015 15:27:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:subject:to:cc:message-id:in-reply-to:references :mime-version:content-type; bh=kkzuhQCHtxC2sIw1jK8KlkLzEhXU1esQDWNaVWEsIm8=; b=rI3bHbMbkE6ogJaUf+h3b7dmWj84oAqCthXPsf8eaD4t93G8B1y7OXQBK+xarllzYw l+OHHNS0eenJflJTdlHS14ah9M3tLBC1+6UdpBuh54CTYXq8j4EofHonB6OqIdTBxxI5 /H+tTRsjgAL7cftEwzCro12io7f6yAw/iO7LPHL2XI/J1Nezh/0JWrnOSrGXeL2I9qbH IKDXlERzOcKVdWaAtVQejA9Adp6+vbk8qHW5huUImqo7fnUQtgvE348ZIVo84A6ZYoZZ oWuxlnfmyHWMLrn1fA6s3nv4dOinF7r1tVkfxJBKcwidm7+7t9CQDJ+VuXVPY5x/GvSA C/7w== X-Received: by 10.112.234.163 with SMTP id uf3mr8654915lbc.15.1446420468493; Sun, 01 Nov 2015 15:27:48 -0800 (PST) Original-Received: from [192.168.100.7] (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id yp7sm3401335lbb.47.2015.11.01.15.27.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Nov 2015 15:27:47 -0800 (PST) In-Reply-To: <1446407553.4906.0@smtp.gmail.com> X-Mailer: geary/0.10.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:108284 Archived-At: --=-uGcAHqT79X22IzxXbJYF Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Hello again, Dmitry. I managed to produce a benchmark with the following JSON file (560K, ~10,000 lines): http://folk.uio.no/simenheg/huge.json. I read it into `huge-json', and ran the following before the patch: (benchmark-run 100 (json-read-from-string huge-json)) =E2=87=92 (19.421527195 938 7.448190372000017) And after the patch: (benchmark-run 100 (json-read-from-string huge-json)) =E2=87=92 (19.321667537 997 7.218977015999971) -- Simen On Sun, Nov 1, 2015 at 8:52 PM, Simen Heggest=C3=B8yl =20 wrote: > Hi Dmitry, thanks for the feedback! >=20 > On Sat, Oct 31, 2015 at 3:23 PM, Dmitry Gutov =20 > wrote: >> The video looks great, but the inline patch lacks indentation, and=20 >> doesn't apply (dunno if the former is the cause of the latter).=20 >> Please resend it as an attachment. >=20 > Ah, yes, it appear that the whitespace got lost in the email for some > reason. I'll try attaching it to this email. >=20 > To test it, I've been using the following interactive function: >=20 > (defun json-mode-show-path () > "Show the path to the JSON value under point." > (interactive) > (let ((path (json-path-to-position (point)))) > (if path > (let ((formatted-path > (json-mode--format-path (plist-get path :path)))) > (pulse-momentary-highlight-region > (plist-get path :match-start) > (plist-get path :match-end)) > (message formatted-path) > (kill-new formatted-path)) > (message "Not a JSON value")))) >=20 > (defun json-mode--format-path (path) > "Return PATH formatted as a JSON data selector. > PATH should be a list of keys, which can be either strings or > integers." > (mapconcat (lambda (key) (format "[%S]" key)) path "")) >=20 > It's also included it in json-mode.el: > http://folk.uio.no/simenheg/json-mode.el. >=20 >> Without trying it, my main concern would be any performance=20 >> regression to json-read (it's not particularly fast already). Have=20 >> you done any benchmarking? >=20 > I agree that would be bad. I'll try to produce some benchmarks when > I've got some free time on my hands! >=20 > -- Simen = --=-uGcAHqT79X22IzxXbJYF Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Hello again, Dmitry.

I managed to produce a b= enchmark with the following JSON file (560K,

I read it into `huge-json', and ran = the following before the patch:

(benchmark-run 100= (json-read-from-string huge-json))
     =E2=87=92= (19.421527195 938 7.448190372000017)

And after th= e patch:

(benchmark-run 100 (json-read-from-string= huge-json))
     =E2=87=92 (19.321667537 997 7.21= 8977015999971)

-- Simen

On Sun, Nov 1, 20= 15 at 8:52 PM, Simen Heggest=C3=B8yl <simenheg@gmail.com> wrote:
Hi Dmitry, thanks for the feedback!

On Sat, Oct 31, 2015 at 3:23 PM= , Dmitry Gutov <dgutov@yandex.ru> wrote:
The video looks = great, but the inline patch lacks indentation, and doesn't apply (dunno if = the former is the cause of the latter). Please resend it as an attachment.<= /div>

Ah, yes, it appear that the whit= espace got lost in the email for some
reason. I'll try attaching = it to this email.

To test it, I've been using the = following interactive function:

  (defun json= -mode-show-path ()
    "Show the path to the JSON value= under point."
    (interactive)
   = ; (let ((path (json-path-to-position (point))))
    &nb= sp; (if path
          (let ((formatted-= path
                &nbs= p;(json-mode--format-path (plist-get path :path))))
   =         (pulse-momentary-highlight-region
&n= bsp;            (plist-get path :match-start)=
             (plist-get path = :match-end))
            (message f= ormatted-path)
            (kill-ne= w formatted-path))
        (message "Not a JS= ON value"))))
  
  (defun json-mode--for= mat-path (path)
    "Return PATH formatted as a JSON da= ta selector.
  PATH should be a list of keys, which can be e= ither strings or
  integers."
    (mapco= ncat (lambda (key) (format "[%S]" key)) path ""))

= It's also included it in json-mode.el:

Without trying it, my main concern would be any perfo= rmance regression to json-read (it's not particularly fast already). Have y= ou done any benchmarking?

I agree that would be = bad. I'll try to produce some benchmarks when
I've got some free = time on my hands!

-- Simen
= --=-uGcAHqT79X22IzxXbJYF--