diff options
author | default <nobody@localhost> | 2023-08-03 08:42:38 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2023-08-03 08:42:38 +0200 |
commit | 2137d2f13310aca3cef6a0fc7735fdf4aac53e8c (patch) | |
tree | 69d426ca8e14ff509a9cdd94d443b81bf975e7a0 /xs_json.h | |
parent | d455280705700cf75b4b7a59218cf48d4684ae68 (diff) |
Backport from xs.
Diffstat (limited to 'xs_json.h')
-rw-r--r-- | xs_json.h | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -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) */ |