From: Petri Lehtinen Date: Thu, 30 Jun 2011 18:48:51 +0000 (+0300) Subject: Merge branch '2.1' X-Git-Tag: v2.2~3 X-Git-Url: http://www.project-moonshot.org/gitweb/?a=commitdiff_plain;h=7e9c293986de8bcb88dbb4b8dfa155e4d2834ed6;hp=-c;p=jansson.git Merge branch '2.1' --- 7e9c293986de8bcb88dbb4b8dfa155e4d2834ed6 diff --combined doc/apiref.rst index efafd12,4051b38..df20a3a --- a/doc/apiref.rst +++ b/doc/apiref.rst @@@ -765,26 -765,6 +765,26 @@@ is in UTF-8 *path* already exists, it is overwritten. *flags* is described above. Returns 0 on success and -1 on error. +.. type:: json_dump_callback_t + + A typedef for a function that's called by + :func:`json_dump_callback()`:: + + typedef int (*json_dump_callback_t)(const char *buffer, size_t size, void *data); + + *buffer* points to a buffer containing a chunk of output, *size* is + the length of the buffer, and *data* is the corresponding + :func:`json_dump_callback()` argument passed through. + + On error, the function should return -1 to stop the encoding + process. On success, it should return 0. + +.. function:: int json_dump_callback(const json_t *json, json_dump_callback_t callback, void *data, size_t flags) + + Call *callback* repeatedly, passing a chunk of the JSON + representation of *root* each time. *flags* is described above. + Returns 0 on success and -1 on error. + .. _apiref-decoding: @@@ -870,14 -850,14 +870,14 @@@ The following functions perform the act Building Values =============== - This sectinon describes functions that help to create, or *pack*, + This section describes functions that help to create, or *pack*, complex JSON values, especially nested objects and arrays. Value building is based on a *format string* that is used to tell the functions about the expected arguments. For example, the format string ``"i"`` specifies a single integer value, while the format string ``"[ssb]"`` or the equivalent ``"[s, s, - b]"`` specifies an array value with two integers and a boolean as its + b]"`` specifies an array value with two strings and a boolean as its items:: /* Create the JSON integer 42 */ @@@ -912,7 -892,7 +912,7 @@@ denotes the C type that is expected as ``o`` (any value) [json_t \*] Output any given JSON value as-is. If the value is added to an array or object, the reference to the value passed to ``o`` is - stealed by the container. + stolen by the container. ``O`` (any value) [json_t \*] Like ``o``, but the argument's reference count is incremented. @@@ -962,10 -942,10 +962,10 @@@ More examples: json_pack("{}"); /* Build the JSON object {"foo": 42, "bar": 7} */ - json_pack("{sisb}", "foo", 42, "bar", 7); + json_pack("{sisi}", "foo", 42, "bar", 7); /* Like above, ':', ',' and whitespace are ignored */ - json_pack("{s:i, s:b}", "foo", 42, "bar", 7); + json_pack("{s:i, s:i}", "foo", 42, "bar", 7); /* Build the JSON array [[1, 2], {"cool": true}] */ json_pack("[[i,i],{s:b]]", 1, 2, "cool", 1);