[Libwebsockets] Lightweight JSON parser in C

FNA aqiruse at gmail.com
Fri Feb 22 23:02:13 CET 2013

I currently use libjson for my json parsing. I would be interested in a
lightweight json parser. Would like to see it work though before i commit
to using it.

On Fri, Feb 22, 2013 at 10:28 AM, "Andy Green (林安廸)" <andy at warmcat.com>wrote:

> Hi -
> Is there any interest in a very lightweight but 100% correct JSON parser?
> I don't mean like you have in a browser where it goes through and spawns
> objects for everything in the JSON.  The idea is it is basically a stateful
> stream reader, which can do something when the object path it is on top of
> matches what you're interested in.
> It does not recurse, nor malloc anything.  You call it with cursor structs
> which start off zero'd and hold all parsing state.  The cursor structs have
> no pointers and may be copied.  You can call the multiple times with the
> same cursor as new JSON pieces come in and it will parse on from the
> previous state; it's a bytewise parser so there are no fragmentation
> issues.  It means you don't need to hold the JSON all at once anywhere but
> can still parse the whole JSON.
> So the style would be parse until the node of interest is held in the
> cursor struct, then you can use a copy of that as a starting point for
> rummaging around.
> I have the parser working - it is very lightweight, the cursor struct is
> the only storage and it's < 256 bytes - but I am a bit stumped about how to
> most flexibly expose the wanted results.  I know what I want it for and can
> hack that up easily, but I am wondering if there are other real-world uses
> for very cheap JSON parsing in C... if so, what does the JSON look like and
> what are the operations needed on it?
> -Andy
> ______________________________**_________________
> Libwebsockets mailing list
> Libwebsockets at ml.**libwebsockets.org <Libwebsockets at ml.libwebsockets.org>
> http://ml.libwebsockets.org/**mailman/listinfo/libwebsockets<http://ml.libwebsockets.org/mailman/listinfo/libwebsockets>

--A programmer started to cuss
--Because getting to sleep was a fuss
--As he lay there in bed
--Looping 'round in his head
--was: while( !asleep() ) sheep++;
--Nothing is impossible! It is merely a matter of figuring out How?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20130222/18753e5a/attachment-0001.html>

More information about the Libwebsockets mailing list