terminate called after throwing an instance of 'simdjson::simdjson_error' what(): TAPE_ERROR: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. Press any key to continue . . .
I've been trying to solve this error but I can't, nothing is wrong with the json I checked it multiple times, here are some code snippets from my code:
Client::Download Client::Download::parse(simdjson::ondemand::object &obj) {
auto sha1 = obj["sha1"].get_string().value();
auto size = obj["size"].get_int64().value();
auto url = obj["url"].get_string().value();
return {
.sha1 = std::string(sha1),
.size = size,
.url = std::string(url)
};
}
Client::ClientDownloads Client::ClientDownloads::parse(simdjson::ondemand::object &obj) {
Client::ClientDownloads download;
auto client_obj = obj["client"].get_object().value();
auto client_mappings_obj = obj["client_mappings"].get_object().value();
auto server_obj = obj["server"].get_object().value();
auto server_mappings_obj = obj["server_mappings"].get_object().value();
auto client = Client::Download::parse(client_obj);
auto client_mappings = Client::Download::parse(client_mappings_obj);
auto server = Client::Download::parse(server_obj);
auto server_mappings = Client::Download::parse(server_mappings_obj);
download.client = client;
download.client_mappings = client_mappings;
download.server = server;
download.server_mappings = server_mappings;
return download;
}
json:
{
"downloads": {
"client": {
"sha1": "9acca901e3564a91250b941cd2c55a55d0b71bca",
"size": 28534222,
"url": ".jar"
},
"client_mappings": {
"sha1": "94b753018a4683ec7c25a33c9048d46fbf9a5db0",
"size": 10413606,
"url": ".txt"
},
"server": {
"sha1": "e003d151668a0eff64c1191972707655e341f8f5",
"size": 57017689,
"url": ".jar"
},
"server_mappings": {
"sha1": "ad7bb6cf9bdb85fd561981e2c4634a9d3292592d",
"size": 7824495,
"url": ".txt"
}
}
}
main:
int main() {
simdjson::ondemand::parser parser;
simdjson::padded_string json = simdjson::padded_string::load("E:/OneDrive/Desktop/simdjson_project/assets/client_download.json");
simdjson::ondemand::document doc = parser.iterate(json);
simdjson::ondemand::object obj = doc["downloads"].get_object().value();
Client::ClientDownloads downloads = Client::ClientDownloads::parse(obj);
std::cout << downloads.client.sha1 << std::endl;
std::cout << downloads.server.sha1 << std::endl;
return 0;
}
I am 100% sure that the path passed in load() is right (I have verified it). I think during parsing simdjson somehow malforms the json.
Tried debugging and bit of testing, for some reason when I try to print download.client instead of only printing out that single object it prints out the entire thing, I am not sure why.