src/json.c

changeset 1556
afdaa70034f8
parent 1551
f3ba964dc8d5
--- a/src/json.c	Sun Dec 07 15:34:46 2025 +0100
+++ b/src/json.c	Sun Dec 07 19:36:51 2025 +0100
@@ -790,6 +790,22 @@
     return result;
 }
 
+CxJsonStatus cx_json_from_string(const CxAllocator *allocator,
+            cxstring str, CxJsonValue **value) {
+    *value = NULL;
+    CxJson parser;
+    cxJsonInit(&parser, allocator);
+    if (cxJsonFill(&parser, str)) {
+        // LCOV_EXCL_START
+        cxJsonDestroy(&parser);
+        return CX_JSON_BUFFER_ALLOC_FAILED;
+        // LCOV_EXCL_STOP
+    }
+    CxJsonStatus status = cxJsonNext(&parser, value);
+    cxJsonDestroy(&parser);
+    return status;
+}
+
 void cxJsonValueFree(CxJsonValue *value) {
     if (value == NULL || value->type == CX_JSON_NOTHING) return;
     switch (value->type) {

mercurial