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)
112112 }
113113 }
114114
115- if (!source. contains ( " __type " ) && ! source.is_array ())
115+ if (source.is_array ())
116116 {
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'" );
118129 }
119130
120131 auto & from_converters =
You can’t perform that action at this time.
0 commit comments