简体   繁体   中英

json to std::string in c++ from an URL

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.

使用cURL之类的库(或其他许多可用的库)来获取URL,然后将结果存储在std::string

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM