diff options
author | Jo-Philipp Wich <jo@mein.io> | 2021-05-04 11:41:17 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2021-05-04 11:49:37 +0200 |
commit | c4d1648ca6c3ac005b75c3b3b0bb79e664bead75 (patch) | |
tree | ff0968c366537455aa1d7bfc42dff81549016e31 /types.h | |
parent | f2eaea3be2ebf87e2837b728e5a0c67eedf296f5 (diff) |
lib: add support for pretty printing JSON to printf() and sprintf()
Honour precision specifiers when parsing `J` format strings to enable or
disable JSON pretty printing.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'types.h')
-rw-r--r-- | types.h | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -355,8 +355,11 @@ uc_value_t *ucv_from_json(uc_vm *, json_object *); json_object *ucv_to_json(uc_value_t *); char *ucv_to_string(uc_vm *, uc_value_t *); -char *ucv_to_jsonstring(uc_vm *, uc_value_t *); -void ucv_to_stringbuf(uc_vm *, uc_stringbuf_t *, uc_value_t *, bool); +char *ucv_to_jsonstring_formatted(uc_vm *, uc_value_t *, char, size_t); +void ucv_to_stringbuf_formatted(uc_vm *, uc_stringbuf_t *, uc_value_t *, size_t, char, size_t); + +#define ucv_to_jsonstring(vm, val) ucv_to_jsonstring_formatted(vm, val, '\1', 0) +#define ucv_to_stringbuf(vm, buf, val, json) ucv_to_stringbuf_formatted(vm, buf, val, 0, json ? '\1' : '\0', 0) static inline bool ucv_is_callable(uc_value_t *uv) |