Generating JSON output from Databases on the Command Line
April 17, 2011 on 12:00 pm | In software-dev | 1 CommentHello, JSON fans,
This morning i wrote a small C application which can be used to fetch data from sqlite3 and MySQLv5 databases and convert it to JSON. While it was originally written as a test app for my C JSON library, it certainly has other uses.
It can be found here:
http://fossil.wanderinghorse.net/repos/cson/index.cgi/wiki/select-to-json
It “should” compile fine out of the box on any Linux-like system with gcc, bash, and GNU Make. Building on other platforms requires either converting the included Makefile logic to the platform’s build tool, or linking it against the “amalgamation build” of the underlying JSON library. The code is portable ANSI C-89 and should not require any platform-specific fixes.
Happy Hacking!
—– stephan beal
JSON-centric CGI Applications in C
April 11, 2011 on 10:38 pm | In software-dev | 1 CommentHello, fellow C hackers, (everyone else can stop reading now)
A few months ago i started writing cson (pronounced “season”), a C library for generating and consuming JSON data using an OO interface (as opposed to a printf()-like API). The past few days i’ve extended it to support a mini-framework for writing JSON-only CGI applications. It’s biggest claim to fame is that it can use HTTP cookies (or a client-provided session ID) to manage persistent application sessions, which are stored (of course) as JSON. It currently supports using files, sqlite3, or mysql5 for session storage, and can easily be extended to support new back-ends. (So far i have been unable to find any other C/C++ CGI libraries which support persistent sessions.)
If you just happen to be one of the 3 or 4 remaining C hackers who like to write CGI apps, and you are also a big fan of JSON, the code might be of interest to you:
http://fossil.wanderinghorse.net/repos/cson/index.cgi/wiki/cson_cgi
The JSON-based session support is actually independent of the CGI bits, and can be used without HTTP/CGI:
http://fossil.wanderinghorse.net/repos/cson/index.cgi/wiki/cson_session
Here’s a demo:
http://fossil.wanderinghorse.net/demos/cson/
Happy Hacking!
—– stephan beal
Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds.
Valid XHTML and CSS. ^Top^