本文整理汇总了C++中json_ref::set方法的典型用法代码示例。如果您正苦于以下问题:C++ json_ref::set方法的具体用法?C++ json_ref::set怎么用?C++ json_ref::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类json_ref
的用法示例。
在下文中一共展示了json_ref::set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: query_caps
static bool query_caps(
json_ref& response,
json_ref& result,
const json_ref& arr,
bool required) {
size_t i;
bool have_all = true;
for (i = 0; i < json_array_size(arr); i++) {
const auto& ele = arr.at(i);
const char* capname = json_string_value(ele);
bool have = w_capability_supported(json_to_w_string(ele));
if (!have) {
have_all = false;
}
if (!capname) {
break;
}
result.set(capname, json_boolean(have));
if (required && !have) {
char *buf = NULL;
ignore_result(asprintf(
&buf,
"client required capability `%s` is not supported by this server",
capname));
response.set("error", typed_string_to_json(buf, W_STRING_UNICODE));
w_log(W_LOG_ERR, "version: %s\n", buf);
free(buf);
// Only trigger the error on the first one we hit. Ideally
// we'd tell the user about all of them, but it is a PITA to
// join and print them here in C :-/
required = false;
}
}
return have_all;
}