Move JSON helpers to lib

This commit is contained in:
WarmUpTill
2025-04-17 11:51:00 +02:00
committed by WarmUpTill
parent 7c4c0056ce
commit 5568f92ad0
13 changed files with 64 additions and 58 deletions

View File

@@ -51,3 +51,18 @@ TEST_CASE("MatchJson", "[json-helpers]")
result = advss::MatchJson("{\n \"test\": true\n}\n", "(", regex);
REQUIRE(result == false);
}
TEST_CASE("GetJsonField", "[utility]")
{
auto result = advss::GetJsonField("{}", "");
REQUIRE_FALSE(result);
result = advss::GetJsonField("{}", "not there");
REQUIRE_FALSE(result);
result = advss::GetJsonField("invalid json", "not there");
REQUIRE_FALSE(result);
result = advss::GetJsonField("{ \"test\": 1 }", "test");
REQUIRE(*result == "1");
}