-
-
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
Unexpected end of input (not same as one before) #974
Comments
I'm making this post to add something I'd forgotten earlier: |
The error message means that the text you passed to the parser is invalid JSON. If you use the latest version of the library, the error message will be more detailed (e.g. In your linked example, I assume the error stems from line found = m_cache.insert_or_assign(found, query_data, std::make_pair(std::chrono::steady_clock::now(), json::parse(res.body()))); Could you provide the content of |
I believe that This code: std::string host{ "openexchangerates.org" }, api_endpoint{ "/api/latest.json" }, base{ "USD" },
app_id{ "MY_APP_ID" }, symbol{ query_data }, prettyprint{ "true" }, show_alternative{ "false" },
target = api_endpoint + "?app_id=" + app_id + "&base=" + base +
"&symbols=" + symbol + "&prettyprint=" + prettyprint + "&show_alternative=" + show_alternative,
port{ "443" };
int version = 11;
// This object and the TCP socket perform our IO
tcp::resolver resolver{ m_ioc };
// Look up the domain name
const auto results = resolver.resolve(host, port);
// Make the connection on the IP address we get from a lookup
boost::asio::connect(m_socket, results.begin(), results.end());
// Set up an HTTP GET request message
http::request<http::string_body> req{ http::verb::get, target, version };
req.set(http::field::host, host);
req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING);
// Send the HTTP request to the remote host
http::write(m_socket, req); is where I'm trying to construct the host and port strings, get the IP address, and send the request to the remote host. I wonder if the API I'm sending the request to expects a JSON request. If it doesn't, then I don't understand what's wrong since I'm sure I gave it the correct URL. Edit: This is the URL I'm using to query the API: |
Well then we know why there is an error message. I guess there is nothing wrong with the library at this point. |
As the title says, my issue is an "unexpected end of input" error. I have a HTTP web server I'm writing using an example from the Boost.Beast library, and in it I want to send a request to a currency API that gives back its response as JSON data. I'm trying to use this library for that.
I don't know what exactly caused the problem, but I can provide a link to a Gist with all of my code here at least: https://gist.github.com/DragonOsman/9a7d4ee116efc575dece7d6de46bd31d . The HTML and JavaScript files provided are also part of the project and may be needed to reproduce the issue.
The expected behavior for the JSON part is that I should get back a conversion rate as JSON data that would be stored in my cache storage.
The actual behavior is that I have a message that says there's an unexpected input error, and it seems like the response body I was expecting isn't there. There are other problems in the program itself, but I don't think I should talk about them here since this is about the JSON library.
The compiler I'm using is MSVC, latest version. Visual Studio 2017 IDE. OS is Windows 10.
This is not a bug report, just an issue I'm having that I thought I should ask about. Any help would be appreciated. Thanks in advance.
Edit to add: I forgot to say this earlier; I used ParcelJS to build my front-end code to make the
country-currency-map
stuff work. It runs its own server, though, so I had to close that and then run the application which has its own server.The text was updated successfully, but these errors were encountered: