title: Parsing javascript dumped array using Qt into list of points
body: <p>I need to convert a dumped array of points to a list of points in qt using c++ so that I can further debug my application. I use chrome to copy the array object to a file and it will end up like this:</p>
  <pre><code>[
    {
      &quot;x&quot;: 0,
      &quot;y&quot;: 266.48351648351644
    },
    {
      &quot;x&quot;: 2.3095238095238093,
      &quot;y&quot;: 274.3003663003663
    },
    {
      &quot;x&quot;: 3.3754578754578755,
      &quot;y&quot;: 277.6758241758242
    }
  ]
  </code></pre>
  <p>My strategy is to open the file and find lines that have the character x or y in them and save each consecutive x,y in a point object:</p>
  <pre><code>void MainWindow::on_btnOpenFile_clicked()
  {
  
      auto path = QFileDialog::getOpenFileName(this, &quot;Browse for a array object file...&quot;);
      QFile file(path); // works fine
  
      if(file.exists(path) &amp;&amp; file.open(QIODevice::ReadOnly)) {
  
          QTextStream stream(&amp;file);
          QVector&lt;QPointF&gt; points;
          QString currentLine;
          qreal x;
          qreal y;
  
          // Regex rules for x and y
          QRegExp rX(&quot;:.*,&quot;);
          rX.setMinimal(true);
          QRegExp rY(&quot;:.*&quot;);
          rY.setMinimal(true);
  
          while(!stream.atEnd()) {
  
              bool xFound = false, yFound = false;
              currentLine = stream.readLine();
  
              // Get X value
              if(currentLine.contains(&quot;x&quot;, Qt::CaseInsensitive)) {
                  auto pos = rX.indexIn(currentLine);
                  if(pos == 0) {
                      x = rX.capturedTexts()[0].toDouble();
                      xFound = true;
                  }
              } else if(currentLine.contains(&quot;y&quot;, Qt::CaseInsensitive)) { // Get Y value
                  auto pos = rY.indexIn(currentLine);
                  if(pos == 0) {
                      y = rY.capturedTexts()[0].toDouble();
                      yFound = true;
                  }
              }
  
              if(xFound)
              points.push_back({x,y});
  
          }
      }
  
  }
  </code></pre>
  <p>I just noticed that my approach will not work because I only evaluate one line in each iteration of the while loop...and that will never work.</p>
  <p>Second is my regex that even matches the <code>[</code> character!</p>
  <p>Is there any smarter way of doing this parsing? the dumped file looks like a JSON to me but maybe not? if it is compatible with JSON is there an automated way of converting it?</p>