Browse Source

Print out some more specifics

This shows different ways to access things.
master
Monty Taylor 3 months ago
parent
commit
b50ca80db9
1 changed files with 7 additions and 0 deletions
  1. 7
    0
      zuul-preview/main.cc

+ 7
- 0
zuul-preview/main.cc View File

@@ -29,7 +29,14 @@ int main(int, char**)
29 29
   auto response = client.request(
30 30
     web::http::methods::GET,
31 31
      "/api/tenant/openstack/build/75031cad206c4014ad7a3387091d15ab").get();
32
+  // body is a web::json::value
32 33
   auto body = response.extract_json().get();
33 34
   cout << response.status_code() << endl;
34 35
   cout << body.serialize() << endl;
36
+  // body["log_url"] returns a web::json::value
37
+  cout << "The log url is " << body["log_url"] << endl;
38
+  // body["log_url"].as_string() returns a const std::string&
39
+  cout << "The log url is " << body["log_url"].as_string() << endl;
40
+  // body.at("log_url").as_string() returns a const std::string&
41
+  cout << "The log url is " << body.at("log_url").as_string() << endl;
35 42
 }

Loading…
Cancel
Save