emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I created a faster JSON parser


From: Herman , Géza
Subject: Re: I created a faster JSON parser
Date: Fri, 08 Mar 2024 13:34:04 +0100


Philip Kaludercic <philipk@posteo.net> writes:

"Herman, Géza" <geza.herman@gmail.com> writes:

It replaces json-parse-string and json-parse-buffer functions. The behavior should be the same as before, with the only exception that objects with duplicated keys are not detected if :object-type is not
'hash-table.

Is that a problem?
Not sure. I just mentioned it because it's a behavior change. But I intentionally designed it this way, because it is faster. To me, it makes some sense that if the user specifies 'alist or 'plist, then they want to have all the object members, even if the keys are duplicated. I didn't find a clear direction from JSON descriptions of how duplicated keys should be handled.

This parser runs 8-9x faster than the jansson based parser on my machine (tested on clangd language server messages). An additional tiny benefit is that large integers are parsed, instead of having an
"out of range" error.

That sounds interesting, but I am reminded of this article:
https://seriot.ch/projects/parsing_json.html. There seem to be plenty of difficult edge-cases when dealing with JSON input, that should
probably be tested if Emacs has it's own custom parser built-in.
I've now run my parser on the tests in this repo, it passes all of them.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]