#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);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writecallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
res = curl_easy_perform(curl);
if (res != CURLE_OK) {
printf("Error");
}
curl_easy_strerror(res);
curl_easy_cleanup(curl);
curl_global_cleanup();
// printf(readBuffer.c_str());
return readBuffer;
}
}
int main()
{
Json::Reader reader;
Json::Value root;
std::string text = ReadWebsite("https://pastebin.com/raw/PW13MZjp");
if (reader.parse(text.c_str(), root)) {
cout << root["addresses"];
}
}
C4996: 'Json::Reader' Use CharReader and CharReaderBuilder instead.
C4996: 'Json::Reader::__autoclassinit2' Use CharReader and CharReaderBuilder instead.
C4996: 'Json::Reader::Reader' Use CharReader and CharReaderBuilder instead.
C4996: 'Json::Reader::parse' Use CharReader and CharReaderBuilder instead.
if i use CharReader and CharReadBuilder i get a Exception thrown at 0x79781F4C (ucrtbased.dll) in ConsoleApplication2.exe: 0xC0000005: Access violation reading location 0xCCCCCCCC.
Code with CharReader and CharReadBuilder
int main()
{
std::string Reply = ReadWebsite("https://pastebin.com/raw/PW13MZjp");
const auto rawJsonLength = static_cast<int>((Reply).length());
JSONCPP_STRING err;
Json::Value root;
Json::CharReaderBuilder builder;
const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
if (!reader->parse((Reply).c_str(), Reply.c_str() + rawJsonLength, &root,&err)) {
MessageBoxA(NULL,"error","error",MB_OK);
return EXIT_FAILURE;
}
printf("%s\n\n",root["offsets"]["ls_offset"]);
system("pause");
}
Any help ill accept. Thanks!
User contributions licensed under CC BY-SA 3.0