Fix parsing empty json object. (#4868)

* Fix parsing empty json object.

* Better error message.
This commit is contained in:
Jiaming Yuan
2019-09-18 03:31:46 -04:00
committed by GitHub
parent 006eb80578
commit 57106a3459
2 changed files with 29 additions and 2 deletions

View File

@@ -214,6 +214,20 @@ TEST(Json, Null) {
ASSERT_TRUE(IsA<Null>(json["key"]));
}
TEST(Json, EmptyObject) {
std::string str = R"json(
{
"rank": 1,
"statistic": {
}
}
)json";
std::stringstream iss(str);
auto json = Json::Load(StringView{str.c_str(), str.size()});
ASSERT_TRUE(IsA<Object>(json["statistic"]));
}
TEST(Json, EmptyArray) {
std::string str = R"json(
{