Bwar / CJsonObject

Ultralightweight JSON parser in C++ based on cJSON
MIT License
648 stars 239 forks source link

有关CJsonObject []和=重载符的疑问 #60

Closed Ender29 closed 1 year ago

Ender29 commented 1 year ago

`

include

include "json/CJsonObject.hpp"

using namespace std; using namespace neb;

int main() { / { "test": { "test2": 1 } } / std::string data = "{\"test\":{\"test2\":1}}"; cout << data << endl;

CJsonObject a, b, c;
a.Parse(data);
b = a;

int t = -1;
a["test"].Get("test2", t);
cout << "t: " << t << endl;

b["test"].Replace("test2", 2);
b["test"].Get("test2", t);
cout << "t: " << t << endl;

a = b;
a["test"].Get("test2", t);
cout << "t: " << t << endl;

a.Get("test", c);
c.Get("test2", t);
cout << "t: " << t << endl;

system("pause");
return 0;

} ` image

第三个结果 期望是 2 吧,等于操作的时候是不是也需要清空map []里的map是为了性能上的优化吗

Ender29 commented 1 year ago

刚发现最新版的已经没这个问题了。。。