summaryrefslogtreecommitdiffstats
path: root/src/json.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/json.c')
-rw-r--r--src/json.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/json.c b/src/json.c
index c9c2078..239f601 100644
--- a/src/json.c
+++ b/src/json.c
@@ -18,6 +18,21 @@ int og_json_parse_string(json_t *element, const char **str)
return 0;
}
+int og_json_parse_string_copy(json_t *element, char *str, size_t size)
+{
+ const char *reference_str;
+ int err = 0;
+
+ err = og_json_parse_string(element, &reference_str);
+ if (err != 0)
+ return err;
+
+ err = snprintf(str, size, "%s", reference_str);
+ if (err >= size)
+ return -1;
+ return 0;
+}
+
int og_json_parse_uint64(json_t *element, uint64_t *integer)
{
if (json_typeof(element) != JSON_INTEGER)