Re: [Cppcms-users] Is there any way to get a list of key values from a JSON object?
Brought to you by:
artyom-beilis
From: Daniel V. <chi...@gm...> - 2012-05-10 17:49:39
|
using cppcms; try { json::value v; ... // test if object "types" exist json::object& o types = v.at("types").object(); // note that "o" is a std::map for ( json::object::iterator i = o.begin; i != o.end(); ++i) { // i->first contains key name // i->second contains mapped value ... } } catch(json::bad_value_cast const& e) { //error handling } Reference: http://cppcms.com/cppcms_ref/latest/classcppcms_1_1json_1_1value.html#aa42bb35c356312bdee5a37bc0350264c http://cppcms.com/cppcms_ref/latest/classcppcms_1_1json_1_1value.html#ac8bcaa686b3ec1ad0cc22d663bce4566 http://cppcms.com/cppcms_ref/latest/namespacecppcms_1_1json.html#a4849268540ccdea30cfa408d6706d0c9 > Would it be possible for me to query the JSON value object to find out > that there are two "type" values in the "imageservice" bit, and that > those types had keys of "test-type-1" and "test-type-2"? > I've been trying & failing to achieve this. > Thanks for any & all help, > Doug. |