diff options
| author | 2023-08-05 14:44:25 +0200 | |
|---|---|---|
| committer | 2023-08-05 14:44:25 +0200 | |
| commit | d8f2bb11281f2ac5c52db49d39aaabdbcf3030a8 (patch) | |
| tree | fdd86e8b7d434f6827bdcf8a2985973a09427897 /xs_json.h | |
| parent | Moved avatars to artwork/. (diff) | |
| download | snac2-d8f2bb11281f2ac5c52db49d39aaabdbcf3030a8.tar.gz snac2-d8f2bb11281f2ac5c52db49d39aaabdbcf3030a8.tar.xz snac2-d8f2bb11281f2ac5c52db49d39aaabdbcf3030a8.zip | |
Partial import of xs_json_load() from xs.
Diffstat (limited to '')
| -rw-r--r-- | xs_json.h | 10 |
1 files changed, 10 insertions, 0 deletions
| @@ -8,6 +8,7 @@ xs_str *xs_json_dumps_pp(const xs_val *data, int indent); | |||
| 8 | int xs_json_dump_pp(const xs_val *data, int indent, FILE *f); | 8 | int xs_json_dump_pp(const xs_val *data, int indent, FILE *f); |
| 9 | #define xs_json_dumps(data) xs_json_dumps_pp(data, 0) | 9 | #define xs_json_dumps(data) xs_json_dumps_pp(data, 0) |
| 10 | xs_val *xs_json_loads(const xs_str *json); | 10 | xs_val *xs_json_loads(const xs_str *json); |
| 11 | xs_val *xs_json_load(FILE *f); | ||
| 11 | 12 | ||
| 12 | 13 | ||
| 13 | #ifdef XS_IMPLEMENTATION | 14 | #ifdef XS_IMPLEMENTATION |
| @@ -539,6 +540,15 @@ xs_val *xs_json_loads(const xs_str *json) | |||
| 539 | return v; | 540 | return v; |
| 540 | } | 541 | } |
| 541 | 542 | ||
| 543 | |||
| 544 | xs_val *xs_json_load(FILE *f) | ||
| 545 | /* loads a JSON file */ | ||
| 546 | { | ||
| 547 | xs *o = xs_readall(f); | ||
| 548 | return o ? xs_json_loads(o) : NULL; | ||
| 549 | } | ||
| 550 | |||
| 551 | |||
| 542 | #endif /* XS_IMPLEMENTATION */ | 552 | #endif /* XS_IMPLEMENTATION */ |
| 543 | 553 | ||
| 544 | #endif /* _XS_JSON_H */ | 554 | #endif /* _XS_JSON_H */ |