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

Function test_json

lib_acl/samples/json/json7/main.cpp:6–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4#include "lib_acl.h"
5
6static void test_json(const char *data, ACL_ARGV *names)
7{
8 ACL_JSON *json = acl_json_alloc();
9 ACL_VSTRING *buf = acl_vstring_alloc(1024);
10 ACL_ITER iter, iter2;
11
12 acl_json_update(json, data);
13
14 if (!acl_json_finish(json)) {
15 printf("Invalid json!\r\n");
16 return;
17 }
18
19#define STR acl_vstring_str
20#define LEN ACL_VSTRING_LEN
21#define EQ !strcmp
22
23 acl_foreach(iter, json) {
24 ACL_JSON_NODE* node = (ACL_JSON_NODE*) iter.data;
25 if (LEN(node->ltag) == 0) {
26 continue;
27 }
28
29 acl_foreach(iter2, names) {
30 const char *name = (const char*) iter2.data;
31 if (EQ(STR(node->ltag), name)) {
32 acl_json_node_disable(node, 1);
33 }
34 }
35 }
36
37 acl_json_build(json, buf);
38 printf("%s\r\n", STR(buf));
39 acl_json_free(json);
40 acl_vstring_free(buf);
41}
42
43static void usage(const char *procname)
44{

Callers 1

mainFunction · 0.70

Calls 7

acl_json_allocFunction · 0.85
acl_vstring_allocFunction · 0.85
acl_json_updateFunction · 0.85
acl_json_finishFunction · 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…