[promo_api] client-server data format is changed. Optional fields are used instead of nullable.

This commit is contained in:
Arsentiy Milchakov 2019-06-19 19:25:36 +03:00 committed by Tatiana Yan
parent 6f6f55e554
commit 06a69067f3
2 changed files with 6 additions and 21 deletions

View file

@ -59,31 +59,19 @@ void ParseCityGallery(std::string const & src, promo::CityGallery & result)
auto const obj = json_array_get(dataArray, i);
FromJSONObject(obj, "name", item.m_name);
FromJSONObject(obj, "url", item.m_url);
auto const imageUrlObj = json_object_get(obj, "image_url");
if (!json_is_null(imageUrlObj))
FromJSON(imageUrlObj, item.m_imageUrl);
FromJSONObject(obj, "access", item.m_access);
auto const tierObj = json_object_get(obj, "tier");
if (!json_is_null(tierObj))
FromJSON(tierObj, item.m_tier);
FromJSONObjectOptionalField(obj, "image_url", item.m_imageUrl);
FromJSONObjectOptionalField(obj, "tier", item.m_tier);
auto const authorObj = json_object_get(obj, "author");
FromJSONObject(authorObj, "key_id", item.m_author.m_id);
FromJSONObject(authorObj, "name", item.m_author.m_name);
auto const luxCategoryObj = json_object_get(obj, "lux_category");
if (!json_is_null(luxCategoryObj))
if (json_is_object(luxCategoryObj))
{
auto const luxCategoryName = json_object_get(luxCategoryObj, "name");
if (!json_is_null(luxCategoryName))
FromJSON(luxCategoryName, item.m_luxCategory.m_name);
auto const luxCategoryColor = json_object_get(luxCategoryObj, "color");
if (!json_is_null(luxCategoryColor))
FromJSON(luxCategoryColor, item.m_luxCategory.m_color);
FromJSONObjectOptionalField(luxCategoryObj, "name", item.m_luxCategory.m_name);
FromJSONObjectOptionalField(luxCategoryObj, "color", item.m_luxCategory.m_color);
}
result.m_items.emplace_back(std::move(item));

View file

@ -539,13 +539,10 @@ PROMO_GALLERY_CITY = """
"key_id": "00000000-0000-0000-0000-000000000000",
"name": "Bmj"
},
"image_url": null,
"access": "public",
"lux_category": {
"name": null,
"color": "000000"
},
"tier": null
}
}
],
"errors": [],