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

Function main

lib_acl_cpp/samples/json/json9/json.cpp:37–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36#include <iostream>
37int main()
38{
39#if 1
40 const char* sss =
41 "[{\"DataKey1\": \"BindRule\", \"DataValue\": {\"waittime\": \"7\"}, \"null_key\": \"null\"},\r\n"
42 "{\"DataKey2\": \"BindRule\", \"DataValue\": {\"waittime\": \"7\"}, \"null_key\": \"null\"},\r\n"
43 "{\"member\": [25, 26, 27, 28, 29, true, false]},\r\n"
44 "{\"max_uint64\": 18446744073709551615},\r\n"
45 "[\"string\", true, false, 100, 200, 300, null, null],\r\n"
46 "{\"hello world\": true, \"name\": null, \"age\": 25}]\r\n"
47 "{\"hello\" : \"world\"} \r\n";
48#else
49 const char* sss = "{\"name\": \"100\"}";
50#endif
51
52 acl::json json;
53 const char* ptr = json.update(sss);
54
55 printf("-------------------------------------------------------\r\n");
56
57 printf("%s\r\n", sss);
58
59 printf("-------------------------------------------------------\r\n");
60
61 printf("json finish: %s, left char: %s\r\n",
62 json.finish() ? "yes" : "no", ptr);
63
64 printf(">>>to string: %s\r\n", json.to_string().c_str());
65
66 const char* ss =
67 "[{\"DataKey1\": \"BindRule\", \"DataValue\": {\"waittime\": \"7\"}, \"null_key\": \"null\"}, "
68 "{\"DataKey2\": \"BindRule\", \"DataValue\": {\"waittime\": \"7\"}, \"null_key\": \"null\"}, "
69 "{\"member\": [25, 26, 27, 28, 29, true, false]}, "
70 "{\"max_uint64\": 18446744073709551615 }, "
71 "[\"string\", true, false, 100, 200, 300, null, null], "
72 "{\"hello world\": true, \"name\": null, \"age\": 25}]";
73
74 printf("-------------------------------------------------------\r\n");
75
76 acl::string buf1(json.to_string()), buf2(ss);
77
78 buf1.trim_space().trim_line();
79 buf2.trim_space().trim_line();
80
81 if (buf1 == buf2)
82 printf("All OK\r\n\r\n");
83 else
84 {
85 printf("Error\r\n");
86 printf("-------------------------------------------------------\r\n");
87 printf("%s\r\n", ss);
88 printf("-------------------------------------------------------\r\n");
89 printf("%s\r\n", json.to_string().c_str());
90 printf("\r\n");
91 exit (1);
92 }
93
94

Callers

nothing calls this directly

Calls 6

test_int64Function · 0.85
test_typeFunction · 0.70
updateMethod · 0.45
finishMethod · 0.45
c_strMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…