void user_posts_saving(Json root, string userID){ Json data = root.object_find("data"); vector<Json> tmp = data.array_get(); if(tmp.size() != 0){ for(int i = 0; i < tmp.size(); i++){ Json from = tmp[i].object_find("from"); //cout << from.get() << endl; //cout << from.value_get() << endl; Json id = from.object_find("id"); string idString = id.value_get(); //cout << id.value_get() << endl; if(idString == userID){ Json message = tmp[i].object_find("message"); //cout << message.value_get() << endl; userPosts.push_back(message.value_get()); } } } }
void likes_mapping(Json root){ Json data = root.object_find("data"); vector<Json> tmp = data.array_get(); if(tmp.size() != 0){ for(int i = 0; i < tmp.size(); i++){ Json id = tmp[i].object_find("id"); string idString = id.value_get(); //cout << idString << endl; //if(idString == userID) printf("自讚!!\n"); bool flag = false; for(int j = 0; j < peoples.size(); j++){ if(peoples[j].id == idString){ peoples[j].likeTimes++; flag = true; } } if(!flag){ People tmp = (People) {idString, 1}; peoples.push_back(tmp); } } } }