crazy2be - 2009-12-05

Is there any way to iterate over a bunch of key-value pairs? For example, say i have the following JSON code:

    "Menu/Background": {
      "UnifiedSize": "{{0.0,0.0},{0.0,0.0},{1.0,0},{1.0,0}}",
      "Type": "WindowsLook/StaticImage",
      "Menu/NewGame": {
        "Type": "WindowsLook/Button",
        "UnifiedSize": "{{0.0,2.0},{0.0,2.0},{1.0,2.0},{0.4,0.0}}",
        "NormalImage": "{\"set\":\"Buttons\", \"image\": \"ButtonUp\"}"
      },
      "Menu/SaveGame": {
        "Type": "WindowsLook/Button",
        "UnifiedSize": "{{0.2,0.0},{0.4,0.0},{0.6,0.0},{0.6,0.0}}"
      }
    }

I want to be able to to do a couple of things. First, find and loop over the name-value arrays without knowing their name. So, basically:

    Json::Value root;
    // Pretend i load the document
    for (int i = 0; i < root.size(); i++) {
       if (root_.type() == Json::valueType::arrayType) {
          std::string name = root.getName();
          // do the same for each child, and do something with this info
        }
    }

in this case, name would now hold "Menu/Background", then "Menu/NewGame", then "Menu/SaveGame".

Is there any way to do this in jsoncpp? I know i can do it with array data types, but it doesn't seem to work with "map" types._