Closed Graullon closed 6 years ago
@Graullon I am not at home, I'll answer this night
I'll try from my mobile:
These types aren't meant to be constructed by the user itself, but anyway, you can construct this object by passing a valid Json::Value object containing the json object for user object
const std::string serializedJson = "{ ...";
Json::Reader reader;
Json::Value userObject;
reader.parse(serializedJson,userObject);
User u(userObject);
So you have to store the JSON serialized object into your file
Sorry for the inconvenience.
Yes, I have already tried next solution for 'User':
Json::Value value(Json::objectValue);
value["first_name"] = "";
value["last_name"] = "";
value["username"] = "";
value["language_code"] = "";
value["id"] = 0;
value["is_bot"] = false;
and just passed it as argument. Thank you a lot for your time, maybe it also will be good to make one more constructor, that will allow to construct those objects from specified values, take a look at this proposition :)
@Graullon It worked?
@StefanoBelli, yes, it worked.
Closing issue
Hello! The main idea what I want to do is: save the object of structure 'User' to the file and than read saved information back. Step with saving info is easy and clean, but when I try to do opposite things the problems appear. The problem is because I can't find a way and understand what exactly parameters are all API-interacting types needs in constructor? In documentation they are (for example structure User)
User (const Json::Value &object)
. And what is thisJson::Value
I can't understand and as a conclusion, I can't create object. Can you please take a look and tell what to do? I will also attach some code below.Write to file:
Read from file and what I can't do:
Thanks in advance!