summaryrefslogtreecommitdiff
path: root/xs_json.h
diff options
context:
space:
mode:
Diffstat (limited to 'xs_json.h')
-rw-r--r--xs_json.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/xs_json.h b/xs_json.h
index 388cfe0..d702a85 100644
--- a/xs_json.h
+++ b/xs_json.h
@@ -5,6 +5,7 @@
#define _XS_JSON_H
xs_str *xs_json_dumps_pp(const xs_val *data, int indent);
+int xs_json_dump_pp(const xs_val *data, int indent, FILE *f);
#define xs_json_dumps(data) xs_json_dumps_pp(data, 0)
xs_val *xs_json_loads(const xs_str *json);
@@ -165,6 +166,19 @@ xs_str *xs_json_dumps_pp(const xs_val *data, int indent)
}
+int xs_json_dump_pp(const xs_val *data, int indent, FILE *f)
+/* dumps data into a file as JSON */
+{
+ xs *j = xs_json_dumps_pp(data, indent);
+
+ if (j == NULL)
+ return 0;
+
+ fwrite(j, strlen(j), 1, f);
+ return 1;
+}
+
+
/** JSON loads **/
/* this code comes mostly from the Minimum Profit Text Editor (MPDM) */