On Monday, 2 June 2014 at 00:39:48 UTC, Jonathan M Davis via
Digitalmars-d wrote:
I know that vibe.d uses its own json implementation, but I
don't know
how much of that is part of its public API and how much of that
is
simply used internally: http://vibed.org
In general, I've been pretty happy with vibe.d, and I've heard
that the parser speed of the JSON implementation is good. But I
must admit that I found the API to be fairly obtuse. In order to
do much of anything, you really need to serialize/deserialize
from structs. The JSON objects themselves are pretty impossible
to modify.
I haven't looked at how vibe's parser works, but any very-fast
parser would probably need to support an input stream, so that it
can build out data in parallel to I/O, and do a lot of manual
memory management. E.g. you probably want a stack of reusable
node buffers that you use to add elements to as you scan the JSON
tree, then clone off purpose-sized nodes from the work buffers
when you encounter the end of the definition. Whereas, the
current implementation in std.json only accepts a complete string
and for each node starts with no memory and has to
allocate/reallocate for every fresh piece of information.
Having worked with JSON libraries quite a bit, the key to a good
one is the ability to refer to paths through the data. So besides
the JSON objects themselves, you need something like a "struct
JPath" that represents an array of strings and size_ts, which you
can pass into get, set, has, and count methods. I'd view the lack
of that as the larger issue with the current JSON implementations.