title: Why can't I use the [] operator to access an array in nlohmann's C++ JSON library?
body: <p>I'm using <a href="https://github.com/nlohmann/json" rel="nofollow noreferrer">this</a> JSON library for C++ in order to get information from Twitter's API, which returns a JSON array to my program (that I'm storing in responseData). But when I try to access "name" in the returned array, it doesn't allow me to. </p>
  
  <p>Here is the error I'm getting after the termination of the process:</p>
  
  <blockquote>
  <pre><code>terminate called after throwing an instance of 'nlohmann::detail::type_error'
  what():  [json.exception.type_error.305] cannot use operator[] with array
  </code></pre>
  </blockquote>
  
  <p>And here is the portion of the code that I'm dealing with:</p>
  
  <pre><code>    if(!responseData.empty()&amp;&amp;response_code==0) {
      std::cout&lt;&lt;responseData&lt;&lt;"&lt;---\n";
      std::cout&lt;&lt;nlohmann::json::parse(responseData.c_str())["name"]&lt;&lt;"&lt;!-\n";
  }
  </code></pre>