Hello all! I'm working on a project for one of my classes. In order to begin the project, we have to parse the contents of a file into a JSON object. I'm currently stuck just trying to create the JSON object and could use a bit of help. I am using XCode 4.6 and have included the json.c and json.h files in my project (found here: JSON) .
This is my main method:
The program builds successfully but I keep getting this error and I don't know what is going wrong:
Thread 1: EXC_BAD_ACCESS (code=1, address=0x20)
The error occurs at this line:
And I get the output:
good open
(lldb)
Could someone please help me figure this out? Thanks!
This is my main method:
#include <string>
#include <fstream>
#include <streambuf>
#include <iostream>
#include <cstdlib>
#include "json.h"
using namespace std;
int main () {
ifstream infile;
infile.open ("/Users/kbooras/Desktop/Countries.txt");
if (infile.is_open())
{
cout << "good open \n";
string inputStr((istreambuf_iterator<char>(infile)), istreambuf_iterator<char>());
json_value data = * json_parse(inputStr.c_str());
infile.close();
}
else
{
cout << "Error opening file \n";
}
return 0;
}
The program builds successfully but I keep getting this error and I don't know what is going wrong:
Thread 1: EXC_BAD_ACCESS (code=1, address=0x20)
The error occurs at this line:
json_value data = * json_parse(inputStr.c_str());
And I get the output:
good open
(lldb)
Could someone please help me figure this out? Thanks!