lloyd / yajl

A fast streaming JSON parsing library in C.
http://lloyd.github.com/yajl
ISC License
2.15k stars 435 forks source link

Request: Alternative non-vararg functions to set options #176

Open nncarlson opened 8 years ago

nncarlson commented 8 years ago

The existing yajl_config() and yajl_gen_config() vararg interfaces are very nice for C/C++ code, but they are a problem to interface to from some other languages. In my case I had been treating yajl_config as if its interace were (yajl_handle_h, yajl_option, int) and this worked for awhile, but then broke for one new compiler. To fix this, I'm now carrying around a tiny bit of extra C code (yajl_ext.c) in my project yajl-fort that provides alternative non-vararg functions to set options. It would be very nice if something like those could be incorporated into yajl directly. I'm not suggesting changing yajl_config/yajl_gen_config, only adding some non-vararg alternatives that can be used by those writing yajl bindings for other languages.

nncarlson commented 8 years ago

Here's what I'm thinking as an alternative for yajl_config(); https://github.com/nncarlson/yajl/commit/bde1095bd2bce0c6db61458024a3221854e0eb74 For consistency, alternative(s) would be needed for yajl_gen_config(), but this is more problematic because the option argument is no longer just an integer (0/1), and in one case takes 2 arguments. Perhaps have separate functions for yajl_gen_indent_string and yajl_gen_print_callback options.

mewalig commented 8 years ago

seems like whatever approach libcurl used for curl_easy_setopt() is probably a good one to use here given how widely that library is used