Some day we will have ANSI C compatibility... This change doesn't make
the API backwards incompatible because uint32_t was only used in flags
to json_dump*() and the flags are meant to be used only by ORing
constants and macro output, and actually currently only JSON_INDENT
can be used.
The following functions perform the actual JSON encoding. The result
is in UTF-8.
The following functions perform the actual JSON encoding. The result
is in UTF-8.
-.. cfunction:: char *json_dumps(const json_t *root, uint32_t flags)
+.. cfunction:: char *json_dumps(const json_t *root, unsigned long flags)
Returns the JSON representation of *root* as a string, or *NULL* on
error. *flags* is described above. The return value must be freed
by the caller using :cfunc:`free()`.
Returns the JSON representation of *root* as a string, or *NULL* on
error. *flags* is described above. The return value must be freed
by the caller using :cfunc:`free()`.
-.. cfunction:: int json_dumpf(const json_t *root, FILE *output, uint32_t flags)
+.. cfunction:: int json_dumpf(const json_t *root, FILE *output, unsigned long flags)
Write the JSON representation of *root* to the stream *output*.
*flags* is described above. Returns 0 on success and -1 on error.
Write the JSON representation of *root* to the stream *output*.
*flags* is described above. Returns 0 on success and -1 on error.
-.. cfunction:: int json_dump_file(const json_t *json, const char *path, uint32_t flags)
+.. cfunction:: int json_dump_file(const json_t *json, const char *path, unsigned long flags)
Write the JSON representation of *root* to the file *path*. If
*path* already exists, it is overwritten. *flags* is described
Write the JSON representation of *root* to the file *path*. If
*path* already exists, it is overwritten. *flags* is described
/* 256 spaces (the maximum indentation size) */
static char whitespace[] = " ";
/* 256 spaces (the maximum indentation size) */
static char whitespace[] = " ";
-static int dump_indent(uint32_t flags, int depth, dump_func dump, void *data)
+static int dump_indent(unsigned long flags, int depth, dump_func dump, void *data)
{
if(JSON_INDENT(flags) > 0)
{
{
if(JSON_INDENT(flags) > 0)
{
return dump("\"", 1, data);
}
return dump("\"", 1, data);
}
-static int do_dump(const json_t *json, uint32_t flags, int depth,
+static int do_dump(const json_t *json, unsigned long flags, int depth,
dump_func dump, void *data)
{
switch(json_typeof(json)) {
dump_func dump, void *data)
{
switch(json_typeof(json)) {
-char *json_dumps(const json_t *json, uint32_t flags)
+char *json_dumps(const json_t *json, unsigned long flags)
{
strbuffer_t strbuff;
char *result;
{
strbuffer_t strbuff;
char *result;
-int json_dumpf(const json_t *json, FILE *output, uint32_t flags)
+int json_dumpf(const json_t *json, FILE *output, unsigned long flags)
{
if(!json_is_array(json) && !json_is_object(json))
return -1;
{
if(!json_is_array(json) && !json_is_object(json))
return -1;
return dump_to_file("\n", 1, (void *)output);
}
return dump_to_file("\n", 1, (void *)output);
}
-int json_dump_file(const json_t *json, const char *path, uint32_t flags)
+int json_dump_file(const json_t *json, const char *path, unsigned long flags)
#define JSON_INDENT(n) (n & 0xFF)
#define JSON_INDENT(n) (n & 0xFF)
-char *json_dumps(const json_t *json, uint32_t flags);
-int json_dumpf(const json_t *json, FILE *output, uint32_t flags);
-int json_dump_file(const json_t *json, const char *path, uint32_t flags);
+char *json_dumps(const json_t *json, unsigned long flags);
+int json_dumpf(const json_t *json, FILE *output, unsigned long flags);
+int json_dump_file(const json_t *json, const char *path, unsigned long flags);