enum class Type
{
TOP =0,
LOW =1,
};
struct Info
{
std::string Animated;
int Age;
Type type;
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Info, Animated, Age, type)
};
struct ThumbnailEx
{
int Height;
std::string Url;
int Width;
NLOHMANN_DEFINE_TYPE_INTRUSIVE(ThumbnailEx, Height, Url, Width)
};
struct Image
{
bool Animate;
int Height;
std::vector <Info> IDs;
ThumbnailEx Thumbnail;
std::string Title;
int Width;
NLOHMANN_DEFINE_TYPE_INTRUSIVE(Image, Animate, Height, IDs, Thumbnail, Title, Width)
};
int main()
{
std::string pathToFile = "C:/Users/dell/Desktop/B&B5.0multi Bridge/StateType11.json";
ifstream streamOfFile(pathToFile);
if (nlohmann::json::accept(streamOfFile)) {
cout << "Nothing to complain about!" << endl;
}
else {
cout << "JSON NOT VALID!" << endl;
}
streamOfFile.clear();
streamOfFile.seekg(0, ios::beg);
try
{
auto json = nlohmann::json::parse(streamOfFile);
Image image;
auto iterFind = json.find("Image");
if (iterFind == json.end()) {
return 0;
}
auto subJson = json.at("Image");
subJson.get_to(image);
}