Fixing demo program
This commit is contained in:
21
main.cpp
21
main.cpp
@@ -105,19 +105,21 @@ product_info pinfo_fromjson(json::value root)
|
||||
|
||||
product_info this_product;
|
||||
|
||||
auto better_root = root.as_object();
|
||||
auto root_obj = root.as_object();
|
||||
|
||||
this_product.category = better_root["category"].string.value();
|
||||
this_product.description = better_root["description"].string.value();
|
||||
this_product.is_available = bool(better_root["is_available"]);
|
||||
this_product.manufacturer = better_root["manufacturer"].string.value();
|
||||
this_product.name = better_root["name"].string.value();
|
||||
this_product.price = double(better_root["price"]);
|
||||
this_product.category = root_obj["category"].string.value();
|
||||
this_product.description = root_obj["description"].string.value();
|
||||
this_product.is_available = bool(root_obj["is_available"]);
|
||||
this_product.manufacturer = root_obj["manufacturer"].string.value();
|
||||
this_product.name = root_obj["name"].string.value();
|
||||
this_product.price = double(root_obj["price"]);
|
||||
|
||||
json::array subobj(better_root["reviews"]);
|
||||
auto reviews = root_obj["reviews"].as_array();
|
||||
|
||||
//json::array subobj = better_root["reviews"].as_array();
|
||||
|
||||
|
||||
for (auto& review_data_pre : subobj)
|
||||
for (auto& review_data_pre : reviews)
|
||||
{
|
||||
json::object review_data = review_data_pre.as_object();
|
||||
product_info::review going_in;
|
||||
@@ -140,7 +142,6 @@ json::value pinfo_tojson(product_info input)
|
||||
root += {"description", input.description};
|
||||
root["name"] = input.name;
|
||||
|
||||
|
||||
auto root_review_list = json::array();
|
||||
for (auto& rev : input.reviews) {
|
||||
auto review = json::object();
|
||||
|
Reference in New Issue
Block a user