Category : jsoncpp

I try to read a file as json in C++. #include <json/json.h> #include <fstream> #include <iostream> int main() { std::ifstream template_file("data.json", std::ifstream::binary); Json::Value template_data; template_file >> template_data; std::cout << template_data; return 0; } However, I get the following error when the Json Library is included. $ g++ test_json.cpp -std=c++11 -v Apple clang version 12.0.5 (clang-1205.0.22.9) ..

Read more

I have a following array of objects in JsonCpp::Value: [{"foo": "bar", "baz": ["Hello", "World"]}, {"Hello": "99bottles", "baz": ["bar", "foo"]}, {"beer": "hello", "world": ["foo"]}…. ] I have to iterate over them and alternate them (remove some elements, add another one). I can easily iterate over JsonArray with: for (Json::Value::ArrayIndex i = 0; i != array.size(); i++) ..

Read more

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 ..

Read more

I’m doing a DLL project in C ++ and first of all I’m going to put in the linker which library I want it to link, so I put my own library with jsoncpp and libcurl, but vs doesn’t want to link the librarys at all me I already put their destinations and when I ..

Read more

so i’ve created a test program to test my library i has created (sorry for my bad english) and after i link my library and tested a function, thats give me a error. Unhandled exception at 0x7949FF5C (ucrtbased.dll) in test.exe: 0xC0000005: Access violation reading location 0x006C6365. in get_name here is my code: template<class Ret, class… ..

Read more

#include <iostream> #include <curl/curl.h> #include <fstream> #include <json/json.h> using namespace std; static size_t writecallback(void* contents, size_t size, size_t nmemb, void* userp) { ((std::string*)userp)->append((char*)contents, size * nmemb); return size * nmemb; } std::string ReadWebsite(const char* URL) { CURL* curl; CURLcode res; std::string readBuffer; curl_global_init(CURL_GLOBAL_DEFAULT); curl = curl_easy_init(); if (curl) { curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); ..

Read more

Using JsonCpp, I want to create a function insert_json declared as void insert_json(Json::Value& base, const Json::Value& value, const std::vector<std::string>& key_v) which should give us this result: #include <string> #include <vector> #include <jsoncpp/json/json.h> void insert_json(Json::Value base, const Json::Value& value, const std::vector<std::string>& key_v) { … }; int main() { Json::Value base, value; value = "42"; std::vector<std::string> key_v ..

Read more