JSON generation in C/C++

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

 



We've talked about generating/parsing JSON a few times, and how we've
run into edge cases whenever we've rolled our own functions for that.
I've mentioned this C library a few times, but I'm not sure if I've
actually sent the link to anyone.. Here's a C library for
generating/parsing JSON, written by an ex-cow-orker of mine.

One feedback I've received earlier was that the "DOM-style"
architecture, where you build up the JSON object in-memory and then
dump it out, is not always a good match. If you want to avoid that,
you can pull off a trick like this pseudocode:

write("{")
json.dump(key)
write(":")
json.dump(value)
write(",")
json.dump(key2)
write(":")
json.dump(value2)
write("}")

The above still uses the library for proper string encoding etc, while
letting you control the top-level structure explicitly. And it should
be pretty easy to encapsulate the above in a convenience wrapper, to
make streaming even nicer; something like this pseudocode:

j = StreamingJSONObject(fd)
j.dump(key, value)
j.dump(key2, value2)
j.close()
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux