- 1 int iValue;
- 2 std::string strValue;
- 3 neb::CJsonObject oJson("{\"refresh_interval\":60,"
- 4 "\"dynamic_loading\":["
- 5 "{"
- 6 "\"so_path\":\"plugins/User.so\", \"load\":false, \"version\":1,"
- 7 "\"cmd\":["
- 8 "{\"cmd\":2001, \"class\":\"neb::CmdUserLogin\"},"
- 9 "{\"cmd\":2003, \"class\":\"neb::CmdUserLogout\"}"
- 10 "],"
- 11 "\"module\":["
- 12 "{\"path\":\"im/user/login\", \"class\":\"neb::ModuleLogin\"},"
- 13 "{\"path\":\"im/user/logout\", \"class\":\"neb::ModuleLogout\"}"
- 14 "]"
- 15 "},"
- 16 "{"
- 17 "\"so_path\":\"plugins/ChatMsg.so\", \"load\":false, \"version\":1,"
- 18 "\"cmd\":["
- 19 "{\"cmd\":2001, \"class\":\"neb::CmdChat\"}"
- 20 "],"
- 21 "\"module\":[]"
- 22 "}"
- 23 "]"
- 24 "}");
- 25 std::cout << oJson.ToString() << std::endl;
- 26 std::cout << "-------------------------------------------------------------------" << std::endl;
- 27 std::cout << oJson["dynamic_loading"][0]["cmd"][1]("class") << std::endl;
- 28 oJson["dynamic_loading"][0]["cmd"][0].Get("cmd", iValue);
- 29 std::cout << "iValue = " << iValue << std::endl;
- 30 oJson["dynamic_loading"][0]["module"][0].Get("path", strValue);
- 31 std::cout << "strValue = " << strValue << std::endl;
- 32 std::cout << "-------------------------------------------------------------------" << std::endl;
- 33 oJson.AddEmptySubObject("depend");
- 34 oJson["depend"].Add("nebula", "https://github.com/Bwar/Nebula");
- 35 oJson["depend"].AddEmptySubArray("bootstrap");
- 36 oJson["depend"]["bootstrap"].Add("BEACON");
- 37 oJson["depend"]["bootstrap"].Add("LOGIC");
- 38 oJson["depend"]["bootstrap"].Add("LOGGER");
- 39 oJson["depend"]["bootstrap"].Add("INTERFACE");
- 40 oJson["depend"]["bootstrap"].Add("ACCESS");
- 41 oJson["depend"].AddEmptySubArray("boot");
- 42 CJsonObject ject;
- 43 string iValues;
- 44 for (int i = 0; i < count; i++)
- 45 {
- 46 iValues = pArr[i];
- 47 ject.Add("p", iValues);
- 48 ject.Add("s", 0);
- 49 ject.Add("i", -1);
- 50 std::cout << "pArr:" << ject.ToString() << std::endl;
- 51 oJson["depend"]["boot"].Add(ject);
- 52 ject.Clear();
- 53 }
- 54 std::cout << oJson.ToString() << std::endl;
- 55 std::cout << "-------------------------------------------------------------------" << std::endl;
- 56 std::cout << oJson.ToFormattedString() << std::endl;