本文整理汇总了C++中nlohmann::json::size方法的典型用法代码示例。如果您正苦于以下问题:C++ json::size方法的具体用法?C++ json::size怎么用?C++ json::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nlohmann::json
的用法示例。
在下文中一共展示了json::size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: REQUIRE
REQUIRE(client.getNumClients() == 1);
REQUIRE(client.stopClients(1));
REQUIRE(client.getNumClients() == 0);
REQUIRE_FALSE(client.stopClients(1));
REQUIRE(client.getNumClients() == 0);
REQUIRE(client.startClients(1, 1, mockProtocolFactory, mockContentManagerFactory, server));
REQUIRE(client.getNumClients() == 1);
REQUIRE(client.startClients(2, 2, mockProtocolFactory, mockContentManagerFactory, server));
REQUIRE(client.getNumClients() == 2);
REQUIRE(client.stopClients(1));
REQUIRE(client.getNumClients() == 1);
REQUIRE(client.getNumBytesRead() == 0);
REQUIRE(client.getNumBytesWritten() == 0);
nlohmann::json json = client.toJson();
REQUIRE(json.size() == 2);
REQUIRE(json["numClients"].get<unsigned>() == 1);
REQUIRE(json["workers"].is_object());
REQUIRE(json["workers"].size() == 1);
REQUIRE(json["workers"]["2"].is_array());
REQUIRE(json["workers"]["2"].size() == 2);
REQUIRE(json["workers"]["2"][0].is_object());
REQUIRE(json["workers"]["2"][1].is_object());
nlohmann::json json2 = client.toJson(2);
REQUIRE(json2["found"].get<bool>());
REQUIRE(json2["worker"].is_array());
REQUIRE(json2["worker"].size() == 2);
REQUIRE(json2["worker"][0].is_object());
REQUIRE(json2["worker"][1].is_object());
示例2: from_json
void from_json(const nlohmann::json &j, Tensor &t) {
if ( j.size()!=6 || !j.is_array() )
throw std::runtime_error("Json->Tensor: array w. exactly six coefficients expected.");
t = Tensor(j[0],j[1],j[2],j[3],j[4],j[5]);
}