0

I want to implement something where I will get an URL which will be a link to JSON db, now I need to get the json from this URL and convert it to std:string in a c++ file. Is there any easy way to do this.

1
  • Please specify a platform. Windows comes with a built-in HTTP library (WinInet), on *nix there's libcurl and many others... Commented Mar 12, 2010 at 20:51

2 Answers 2

1

Use a library such as cURL (or one of many others available) to fetch the URL, and then store the result in an std::string.

Sign up to request clarification or add additional context in comments.

2 Comments

I will appreciate if you can demonstrate some code as I havent used cURL before.
cURL is quite well documented. Look for the "easy" API.
0

If you are on Windows then there is no need to use cURL library - try the api call URLOpenBlockingStream. It is not hard to use and will download the JSON response from the server. JSON can be thought of as XML - it is structurally similar although there are noticeable syntactical differences. That said, it shouldn't be too hard to write a simple parser.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.