-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getting error terminate called after throwing an instance of 'std::domain_error' what(): cannot use at() with string #1582
Comments
What’s the JSON you pass to the server? |
this is the json I receive from the server {"link": "ec2-3-121-209-122.eu-central-1.compute.amazonaws.com"} which is the one I am storing in json object |
Which version of the library are you using? |
This line json object = "(result)"; creates an JSON object with value type of json object = json::parse(result); instead? |
@nickaein is right - you created a string with |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
After performing a http get request I receive a json string containing a string. I need to access the link inside this json string. I am using ubuntu. I downloaded the package with the cmd line sudo apt-get install nlohmann-json-dev
#include <stdio.h>
#include <stdlib.h>
#include "json.hpp"
#include <curl/curl.h>
#include
using nlohmann::json;
int main()
{
curl_global_init( CURL_GLOBAL_ALL );
CURL * myHandle;
CURLcode result; // We’ll store the result of CURL’s webpage retrieval, for simple error checking.
myHandle = curl_easy_init ( ) ;
// Notice the lack of major error checking, for brevity
curl_easy_setopt(myHandle, CURLOPT_URL, "https://matiusulung.com/se.json");
result = curl_easy_perform( myHandle);
json object = "(result)";
std::cout<<object.at("link").getstd::string();
curl_easy_cleanup( myHandle );
printf("LibCurl rules!\n");
return 0;
}
The text was updated successfully, but these errors were encountered: