messing around with jstring.

This commit is contained in:
barant committed 2024-12-10 17:10:49 -08:00
1 parent c644d8346f
commit 0baa44d076
6 files changed
+148 -74

No files matched your search

+3 -3
View File
@@ -1,4 +1,4 @@
#!/bin/bash
g++ -g -std=c++20 -o zstring_test zstring_test.cpp -I.. -L.. -lCoreUtils
g++ -g -std=c++20 -o mstring_test mstring_test.cpp -I.. -L.. -lCoreUtils
#g++ -o jstring_test jstring_test.cpp -I.. -L.. -lCoreUtils
#g++ -g -std=c++20 -o zstring_test zstring_test.cpp -I.. -L.. -lCoreUtils
#g++ -g -std=c++20 -o mstring_test mstring_test.cpp -I.. -L.. -lCoreUtils
g++ -o jstring_test jstring_test.cpp -I.. -L.. -lCoreUtils
Binary file not shown.
+15 -37
View File
@@ -3,34 +3,6 @@
int main(int argc, char **argv) {
// coreutils::JString test1;
// std::cout << "empty jstring: [" << test1 << "]." << std::endl;
// test1.set("key1", "data1");
// std::cout << "add key1 jstring: [" << test1 << "]." << std::endl;
// test1.set("key2", "data2");
// std::cout << "add key2 jstring: [" << test1 << "]." << std::endl;
// test1.set("key3", "data3");
// std::cout << test1["key1"] << test1["key2"] << test1["key3"] << std::endl;
// std::cout << test1 << std::endl;
// test1.set("key2", "data5");
// test1.set("key4", "data4");
// std::cout << test1 << std::endl;
// coreutils::JString test2("{\"key1\":[{\"id\":\"1\",\"name\":\"Brad\"},{\"id\":\"2\",\"name\":\"Jenn\"},{\"id\":\"3\",\"name\":\"Skye\"}],\"key2\":\"data5\",\"key3\":\"data3\",\"key4\":\"data4\"}");
// std::cout << test2 << std::endl;
// std::cout << "--------" << std::endl;
// std::cout << test2["key2"] << std::endl;
// std::cout << test2["key1"] << std::endl;
// std::cout << "value: " << test2["key1.name[id=2]"] << std::endl;
// std::cout << "value: " << test2["key1.name[id=3]"] << std::endl;
// test2["key2"] = "newvalue1";
// std::cout << "--------" << std::endl;
// test2 = "newvalue";
// std::cout << test2 << std::endl;
// std::cout << "--------" << std::endl;
// std::cout << "key2: " << test2["key2"] << std::endl;
coreutils::MString test0("{\"Number:\"0\",\"id\":\"XXXXX\"}");
coreutils::JString test1;
coreutils::MString test2;
@@ -39,16 +11,22 @@ int main(int argc, char **argv) {
test1["health"] = "100";
test1["comment"] = "this is a comment";
test1["race"] = "human";
test1["array"] = "[\"test1\",\"test2\",\"test3\"]";
test1["tester"] = "test field";
test1["object1"] = "{\"attr1\":\"value1\",\"attr2\":\"value2\",\"attr3\":\"value3\"}";
std::cout << test1 << std::endl;
test2 = test1["name"];
std::cout << test2 << std::endl;
test2 = test1["health"];
std::cout << test2 << std::endl;
test2 = test1["comment"];
std::cout << test2 << std::endl;
test2 = test1["race"];
std::cout << test2 << std::endl;
// std::cout << "[" << test1["name"] << std::endl;
std::cout << test1["id"] << std::endl;
std::cout << test1["name"] << std::endl;
std::cout << test1["health"] << std::endl;
std::cout << test1["comment"] << std::endl;
std::cout << test1["race"] << std::endl;
std::cout << test1["array"] << std::endl;
std::cout << test1["tester"] << std::endl;
std::cout << test1["object"] << std::endl;
std::cout << test1["object1.attr2"] << std::endl;
return 0;
}