title: Iterate over an array of JSON objects with jsoncpp
body: <p>I have an array of JSON objects, jsonArr say, of the following kind:</p>
  
  <pre><code>[
    { "attr1" : "somevalue",
      "attr2" : "someothervalue"
    },
    { "attr1" : "yetanothervalue",
      "attr2" : "andsoon"
    },
    ...
  ]
  </code></pre>
  
  <p>Using jsoncpp, I'm trying to iterate through the array and check whether each object has a member <code>"attr1"</code>, in which case I would like to store the corresponding value in the vector <code>values</code>.</p>
  
  <p>I have tried things like</p>
  
  <pre><code>Json::Value root;
  Json::Reader reader;
  Json::FastWriter fastWriter;
  reader.parse(jsonArr, root);
  
  std::vector&lt;std::string&gt; values;
  
  for (Json::Value::iterator it=root.begin(); it!=root.end(); ++it) {
    if (it-&gt;isMember(std::string("attr1"))) {
      values.push_back(fastWriter.write((*it)["uuid"]));
    }
  }
  </code></pre>
  
  <p>but keep getting an error message</p>
  
  <pre><code>libc++abi.dylib: terminating with uncaught exception of type Json::LogicError: in Json::Value::find(key, end, found): requires objectValue or nullValue
  </code></pre>