It doesn't seem to be quite as easy as it appears. I have to use MSVC
unfortunately, and I don't believe I can link a MingW-compiled .lib
into the project. I've tried to compile under Visual Studio 2005, and
got through most of the compilation issues with one hack or another.
Here's a list of the changes I had to make:
* Visual Studio 2005 and earlier has no stdint.h file. I grabbed one
linked from Wikipedia.
* snprintf is defined as _snprintf in VS2005. I manually added a
#define to cover that.
* The 'inline' keyword doesn't appear to be supported when compiling
as C. I #define'd 'inline' to nothing to remove it from compilation.
* In utf.h, VS was complaining about int32_t not being defined. I
added #include <stdint.h> to it to fix it.
* In several places, you use a notation that seems to be a compiler
extension. Specifically the singleton definitions for true, false, and
null, and a stream_data variable in json_loads(), all use what looks
like a keyword-based struct constructor rather than positional. E.g.:
static json_t the_true = {
.type = JSON_TRUE,
.refcount = (unsigned int)1
};
Visual Studio 2005 doesn't appear to support this. I removed the
".type =" and such, since the order seems to be the same as in the
struct definition.
After making these changes, though, I'm happy to say it does appear
work! This is great. I was using JSON-C before, but it has several
annoying bugs, and it doesn't seem to be actively maintained. I'm
happy to see that Jansson has just as simple an API, though.
Thanks for your help!
~Jonathan Castello