File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -112,9 +112,20 @@ JsonExporter::ExpectedEntry JsonExporter::fromJson(const nlohmann::json& source)
112
112
}
113
113
}
114
114
115
- if (!source. contains ( " __type " ) && ! source.is_array ())
115
+ if (source.is_array ())
116
116
{
117
- return nonstd::make_unexpected (" Missing field '__type'" );
117
+ if (source.empty ())
118
+ return nonstd::make_unexpected (" Missing field '__type'" );
119
+ const auto & first = source[0 ];
120
+ if (!first.is_object () || !first.contains (" __type" ))
121
+ return nonstd::make_unexpected (" Missing field '__type'" );
122
+ if (!first[" __type" ].is_string ())
123
+ return nonstd::make_unexpected (" Invalid '__type' (must be string)" );
124
+ }
125
+ else
126
+ {
127
+ if (!source.is_object () || !source.contains (" __type" ) || !source[" __type" ].is_string ())
128
+ return nonstd::make_unexpected (" Missing field '__type'" );
118
129
}
119
130
120
131
auto & from_converters =
You can’t perform that action at this time.
0 commit comments