Stack corruption with jsoncpp

  c++, jsoncpp

I am getting stack corruption saying "Run-Time Check Failure #2 – Stack around the variable ‘root’ was corrupted." with following code:

#include <json/json.h>
#include <fstream>
#include <iostream>
#include <string>

int main() {
  Json::Value root;
  Json::Reader reader;
  ifstream file("input.json");
  if (!reader.parse(file, root)) {
    cout << "Failed to parse configurationn"
      << reader.getFormattedErrorMessages();
    return 0;
  }

  file.close();
  cout << root << endl;

  return 0;
}

File input.json contains:

[
  {
    "id": "id"
  }
]

Any idea why this may be happening and how can I debug this?

Thanks in advance!!

Source: Windows Questions C++

LEAVE A COMMENT