Skip to content

Commit

Permalink
Verify that the nlohmann json library gracefully handles UTF-8 BOM at…
Browse files Browse the repository at this point in the history
… the start of the payload (#4775)
  • Loading branch information
ahsonkhan authored Jul 13, 2023
1 parent b54d509 commit 5ea8947
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions sdk/core/azure-core/test/ut/json_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ TEST(Json, create)
EXPECT_EQ(expected, j.dump());
}

TEST(Json, utf8BOM)
{
// Verify that the UTF-8 BOM bytes (0xEF, 0xBB, 0xBF) are skipped when parsing JSON using the
// library.
std::array<uint8_t, 8> v{239, 187, 191, '5'};
json jsonRoot = json::parse(v);
EXPECT_EQ(jsonRoot.get<int>(), 5);
}

TEST(Json, duplicateName)
{
json jsonRoot = json::parse(R"({"KeyName": 1, "AnotherObject": {"KeyName": 2}})");
Expand Down

0 comments on commit 5ea8947

Please sign in to comment.