I'm reading a json value in c++ using
Json::Reader reader
and the value is stored in Json::Value root
This root contains "age" and "id" and I want to convert root["age"] to int.
I tried to convert it to string using .str() but could not get.
Any suggestion?
In jsoncpp
they provide helper methods on the Json::Value
object. You can merely call the asInt()
method on the value to convert it.
int ageAsInt = root["age"].asInt()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With