extract_double_from_json.cpp
#include <boost/json.hpp>
#include <iostream>
int main() {
// Ayrıştırılacak JSON dizesi
std::string json_str = "{\"timestamp\":1675910171.91}";
// JSON dizesini ayrıştır
boost::json::value jv = boost::json::parse(json_str);
// Zaman damgasını double olarak çıkar
double timestamp = jv.as_object()["timestamp"].as_double();
// Sonucu yazdır
std::cout << "Timestamp: " << timestamp << std::endl;
return 0;
}Şu şekilde derleyin:
compile_jsontest.sh
g++ -o jsontest jsontest.cpp -lboost_jsonÖrnek çıktı
jsontest_output.txt
Timestamp: 1.67591e+09If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow