MCPcopy Create free account
hub / github.com/acl-dev/acl / test_json

Function test_json

lib_acl/samples/json/json6/main.cpp:36–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34
35
36static void test_json(void)
37{
38 ACL_JSON *json = acl_json_alloc();
39 const char* ptr = default_data;
40 ACL_VSTRING *buf = acl_vstring_alloc(1024);
41
42 ptr = acl_json_update(json, ptr);
43
44 printf("-------------------------------------------------------\r\n");
45 printf("finish: %s, left char: %s\r\n",
46 acl_json_finish(json) ? "yes" : "no", ptr);
47 printf("-------------------------------------------------------\r\n");
48 printf("\r\n%s\r\n", default_data);
49 printf("-------------------------------------------------------\r\n");
50 printf("\r\n%s\r\n", acl_vstring_str(buf));
51 printf("-------------------------------------------------------\r\n");
52
53 ACL_ARRAY *a = acl_json_getElementsByTags(json, "menuitem2/value");
54 if (a) {
55 ACL_ITER iter;
56
57 acl_foreach(iter, a) {
58 ACL_JSON_NODE* node = (ACL_JSON_NODE*) iter.data;
59 printf("tag=%s, value=%s\r\n",
60 acl_vstring_str(node->ltag),
61 acl_vstring_str(node->text));
62 }
63
64 acl_json_free_array(a);
65 }
66
67 acl_json_build(json, buf);
68 acl_json_free(json);
69 acl_vstring_free(buf);
70}
71
72int main(void)
73{

Callers 1

mainFunction · 0.70

Calls 9

acl_json_allocFunction · 0.85
acl_vstring_allocFunction · 0.85
acl_json_updateFunction · 0.85
acl_json_finishFunction · 0.85
acl_json_free_arrayFunction · 0.85
acl_json_buildFunction · 0.85
acl_json_freeFunction · 0.85
acl_vstring_freeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…