Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/json_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,20 @@ JsonExporter::ExpectedEntry JsonExporter::fromJson(const nlohmann::json& source)
}
}

if(!source.contains("__type") && !source.is_array())
if(source.is_array())
{
return nonstd::make_unexpected("Missing field '__type'");
if(source.empty())
return nonstd::make_unexpected("Missing field '__type'");
const auto& first = source[0];
if(!first.is_object() || !first.contains("__type"))
return nonstd::make_unexpected("Missing field '__type'");
if(!first["__type"].is_string())
return nonstd::make_unexpected("Invalid '__type' (must be string)");
}
else
{
if(!source.is_object() || !source.contains("__type") || !source["__type"].is_string())
return nonstd::make_unexpected("Missing field '__type'");
}

auto& from_converters =
Expand Down
Loading