title: c++, JSON array parsing using nlohmann::json
body: <p>In a json file imported into my c++ program there is such structure as:</p>
  
  <pre><code>{
   "a":"1",
   "ec":[
         {
          "a":"0x00",
          "s":[
               {"a":"0xA0"},
               {"a":"0xA1"},
              ],
          "b":"v1"
         },
         {
          "a":"0x01",
          "s":[
               {"a":"0xB0"},
               {"a":"0xB1"},
              ],
          "b":"v2"
         }
        ]
  }
  </code></pre>
  
  <p>I want to iterate over the <code>"ec"</code> array and get the values of all <code>"a"</code> and for each <code>"a"</code> the same for its <code>s</code> array</p>
  
  <pre><code>vector&lt;string&gt; ec_a; // should contain {"0x00","0x01"}
  vector&lt;string&gt; a1_s; // should contain {"0xA0", "0xA1"}
  vector&lt;string&gt; a2_s; // should contain {"0xB0","0xB1"}
  </code></pre>
  
  <p>first I get the size of <code>ec</code> but from the <a href="https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a875585b0cb6133902066daccd7c9d420.html#a875585b0cb6133902066daccd7c9d420" rel="noreferrer">docs</a> I understood should use iterator for the rest  </p>
  
  <pre><code>int n=j["ec"].size() // n = 2
  for(auto it=j["ec"].begin();it!=j["ec"].end();++it){
    if(it.key() == "a") ec_a.push_back(it.value());
  }
  </code></pre>
  
  <p>but get this exception <code>nlohmann::detail::invalid_iterator at memory location</code> 
  I assume that <code>j["ec"].begin()</code> is incorrect. </p>
  
  <p>how should I do that, Thanks.</p>