Convert json::value to another types

Jul 24, 2014 at 12:39 PM
Hello, I have a Class where there different types like and int and strings
class AllTasks
    int id;
    string project_id;
I trying to convert the json data that I get
void IterateJSONValue(string mystring, AllTasks tasks[])
    json::value obj = json::value::parse(utility::conversions::to_string_t(mystring));

    auto task = obj[L"tasks"];

    for (auto iter = task.as_object().begin(); iter != task.as_object().end(); ++iter)
        auto &taskid = iter->second;

        for (int i=0; i<taskid.size(); i++)
Inside this second for, I tried to put
tasks[i].id = taskid[i][L"id"]
But, of course, I receive the message that is not possible assign the type std::string with json::value.

So, there is a way where I can easily convert json values to another types?
Jul 24, 2014 at 1:35 PM

task[i].id = taskik[i][L"id].as_string()

same goes for .as_integer(), .as_array() and so on!