Subject: Re: bug#21798: 25.0.50; [PATCH] Add support for retrieving paths to JSON elements

From: Dmitry Gutov <[email-masked]>
Date: Tue, 3 Nov 2015 04:00:56 +0200

Hello Simen,

On 11/02/2015 01:27 AM, Simen Heggestøyl wrote:

> 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:  ...

Thanks. In my testing, too, the difference seems to be statistically 
insignificant. That's good.

I have to say, I'm still not very comfortable with mixing it sort of 
alien logic inside json-read-object and json-read-array (would anyone 
else like to chime in with their opinion?).

I do believe we want this functionality, though. One option to tighten 
the implementation is to extract common pieces from json-read-object and 
json-read-array, and implement two new functions using them, but the 
while-loops used there will make avoiding just copying code somewhat 
difficult.

Here's an idea: both json-read-object-1 and json-read-array-2 will 
advise json-read to add the new logic around calls to it (there will 
have to be some guard in the advice, so that recursive calls are run 
unmodified).

And json-path-to-position will locally modify json-readtable to use 
json-read-object-1 and json-read-array-2.

That's just a suggestion, though.