Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

New Post: Problem web::json::value cbegin()

$
0
0
Hi everybody,

I am new with JSON and with C++ REST SDK.
I found some examples and help on the Internet but I have a strange error:
when I want to iterate a web::json::value with cbegin() visual studio tells me cbegin is not a member of web::json::value.
I checked my headers files, the type, press f1 on the type but everything looks good.
Do you have any solutions ?
void DisplayJSONValue(json::value v)
{
    if (!v.is_null())
    {
        // Loop over each element in the object
        for (auto iter = v.cbegin(); iter != v.as_object().cend(); ++iter)
        {
            // It is necessary to make sure that you get the value as const reference
            // in order to avoid copying the whole JSON value recursively (too expensive for nested objects)
            const json::value &key = iter->first;
            const json::value &value = iter->second;

            if (value.is_object() || value.is_array())
            {
                // We have an object with children or an array
                if ((!key.is_null()) && (key.is_string()))
                {
                    std::wcout << L"Parent: " << key.as_string() << std::endl;
                }
                // Loop over each element in the object by calling DisplayJSONValue
                DisplayJSONValue(value);
                if ((!key.is_null()) && (key.is_string()))
                {
                    std::wcout << L"End of Parent: " << key.as_string() << std::endl;
                }
            }
            else
            {
                // Always display the value as a string
                std::wcout << L"Key: " << key.as_string() << L", Value: " << value.to_string() << std::endl;
            }
        }
    }
}
Thanks

Viewing all articles
Browse latest Browse all 4845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>