no callable ‘begin’

Mar 23, 2015 at 4:31 PM
I was using the 1.4 version of the library, and tried to update to 2.4
Unfortunately, I got the above error when attempting to use a new style for loop;

Given the following definition
web::json::value d

This construct now generates the error in the subject.
for (auto f : d[L"flags"])

is this expected?
Mar 23, 2015 at 4:44 PM
Hi wieser_software,

In our 2.0 release we made a breaking change to the JSON portions of the library.

We changed how iteration over json arrays and objects is performed. No longer is an iterator of std::pair<json::value, json::value> returned. Instead there is a separate iterator for arrays and objects on the json::array and json::object class respectively. This allows us to make performance improvements and continue to adjust accordingly. The array iterator returns json::values, and the object iterator now returns std::pair<string_t, json::value>.

Depending on if you are iterating over a JSON object or array you will need to insert as_array() or as_object, for example:
for(const auto &f : d[L"flags"].as_array())
Mar 23, 2015 at 5:10 PM
Thanks for the speedy response. I'll try that tomorrow.