snac2

Fork of https://codeberg.org/grunfink/snac2
git clone https://git.inz.fi/snac2
Log | Files | Refs | README | LICENSE

commit d8f2bb11281f2ac5c52db49d39aaabdbcf3030a8
parent 294675ae9a387e47e1fca6290fe75c0bdf094754
Author: default <nobody@localhost>
Date:   Sat,  5 Aug 2023 14:44:25 +0200

Partial import of xs_json_load() from xs.

Diffstat:
Mxs_json.h | 10++++++++++
1 file changed, 10 insertions(+), 0 deletions(-)

diff --git a/xs_json.h b/xs_json.h @@ -8,6 +8,7 @@ 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); +xs_val *xs_json_load(FILE *f); #ifdef XS_IMPLEMENTATION @@ -539,6 +540,15 @@ xs_val *xs_json_loads(const xs_str *json) return v; } + +xs_val *xs_json_load(FILE *f) +/* loads a JSON file */ +{ + xs *o = xs_readall(f); + return o ? xs_json_loads(o) : NULL; +} + + #endif /* XS_IMPLEMENTATION */ #endif /* _XS_JSON_H */