diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2023-11-15 13:50:15 +0100 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2023-11-15 14:03:11 +0100 |
commit | 992ac5301fc8727d83017b242af2df9895eebfcc (patch) | |
tree | 4fdd21a61b54d368540d6ef65258f97473051381 /src/json.c | |
parent | client: print the server response (diff) | |
download | cimple-992ac5301fc8727d83017b242af2df9895eebfcc.tar.gz cimple-992ac5301fc8727d83017b242af2df9895eebfcc.zip |
implement a command to list runs
Diffstat (limited to 'src/json.c')
-rw-r--r-- | src/json.c | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -6,6 +6,7 @@ */ #include "json.h" +#include "buf.h" #include "log.h" #include "net.h" @@ -108,6 +109,28 @@ destroy_buf: return result; } +int json_new_object(struct json_object **_obj) +{ + struct json_object *obj = json_object_new_object(); + if (!obj) { + json_errno("json_object_new_object"); + return -1; + } + *_obj = obj; + return 0; +} + +int json_new_array(struct json_object **_arr) +{ + struct json_object *arr = json_object_new_array(); + if (!arr) { + json_errno("json_object_new_array"); + return -1; + } + *_arr = arr; + return 0; +} + int json_has(const struct json_object *obj, const char *key) { return json_object_object_get_ex(obj, key, NULL); @@ -254,3 +277,13 @@ int json_set_int_const_key(struct json_object *obj, const char *key, int64_t val { return json_set_int_internal(obj, key, value, json_const_key_flags); } + +int json_append(struct json_object *arr, struct json_object *elem) +{ + int ret = json_object_array_add(arr, elem); + if (ret < 0) { + json_errno("json_object_array_add"); + return ret; + } + return ret; +} |