0
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
// string s = "{\"age\":23,\"study\":{\"language\":{\"one\":\"chinese\",\"subject\":[{\"one\":\"china\"},{\"two\":\"Eglish\"}]}}}";
string s = "{\"age\" : 26,\"person\":[{\"id\":1,\"study\":[{\"language\":\"chinese\"},{\"language1\":\"chinese1\"}],\"name\":\"chen\"},{\"id\":2,\"name\":\"zhang\"}],\"name\" : \"huchao\"}";
ptree pt;
stringstream stream(s);
read_json<ptree>(stream, pt);
int s1=pt.get<int>("age");
cout<<s1<<endl;
string s2 = pt.get<string>("person."".study."".language1");
cout<<s2<<endl;
現在我想要得到language1的值。如何使用boost :: property_tree訪問JSON數組?
你_did_得到「LANGUAGE1」的價值。這是你從上一個'pt.get'語句獲得的字符串;你用's2'存儲了ti。你到底在問什麼? –
我想知道如何通過pt.get語句獲得「language1」的值,但我不知道如何得到它。 – wyz365889