I have a task serialized as JSON:
{
text: "Some task",
status: 1
}
I'm using this function inside a Serialize
namespace:
Task parseTask(std::string task) {
Json::Value root;
Json::Reader reader;
if(reader.parse(task, root, false)) {
std::string text = root["text"].asString();
int status = root["status"].asInt();
Task result(text);
if(status == 1) result.setCompleted();
return result;
}
}
I'm calling the function as follow:
Task t = Serialize::parseTask("{ text: \"Some Task\", status: 1 }");
And compiling with -ljsoncpp
option. However I get:
terminated by signal SIGSEGV (Address boundary error)
I've been sweeping trough JsonCpp documentation but can't seem to find whats wrong with my code.
I haven't looked at your code, but your JSON is not valid. Key names must be surrounded with quotation marks. Try: