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

Function main

lib_acl_cpp/samples/json/json8/json.cpp:3–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include "stdafx.h"
2
3int main()
4{
5 const char* sss =
6 "["
7 "{\"DataKey\":\"BindRule\",\"DataValue\":{\"waittime\":\"7\"},\"null_key\":null},"
8 "{\"DataKey\":\"BindRule\",\"DataValue\":{\"waittime\":\"7\"},\"null_key\":null}"
9 "]";
10
11 acl::json json3(sss);
12 const char* tags = "DataValue";
13
14 printf("----------------------------------------------------\r\n");
15 printf(">>%s\r\n", sss);
16 const acl::string& s = json3.to_string();
17 printf(">>%s\r\n", s.c_str());
18
19 if (json3.to_string() == sss)
20 printf("parse OK, enter any key to continue\r\n");
21 else
22 {
23 printf("parse ERROR\r\n");
24 return 1;
25 }
26
27 getchar();
28
29 printf("----------------------------------------------------\r\n");
30
31 acl::json_node* iter = json3.first_node();
32 while (iter)
33 {
34 const char* tag = iter->tag_name();
35 const char* txt = iter->get_text();
36 printf("tag: %s, txt: %s\r\n", tag ? tag : "null", txt ? txt : "null");
37 if (txt)
38 iter->set_text("hello");
39 printf("tag: %s, txt: %s\r\n", tag ? tag : "null", txt ? txt : "null");
40 iter = json3.next_node();
41 }
42 printf("----------------------------------------------------\r\n");
43
44 const std::vector<acl::json_node*>& nodes = json3.getElementsByTags(tags);
45 if (nodes.empty() == false)
46 printf(">>>%s\r\n", nodes[0]->to_string().c_str());
47
48 return 0;
49}

Callers

nothing calls this directly

Calls 8

get_textMethod · 0.80
set_textMethod · 0.80
to_stringMethod · 0.45
c_strMethod · 0.45
first_nodeMethod · 0.45
tag_nameMethod · 0.45
next_nodeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…