本文整理汇总了C++中json::Object::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ Object::isNull方法的具体用法?C++ Object::isNull怎么用?C++ Object::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类json::Object
的用法示例。
在下文中一共展示了Object::isNull方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleMe
// this method is called when REST response is received for request to get user information:
void handleMe(boost::system::error_code err, const Http::Message& response)
{
#ifndef WT_TARGET_JAVA
WApplication::instance()->resumeRendering();
#endif
if (!err && response.status() == 200) {
#ifndef WT_TARGET_JAVA
Json::ParseError e;
Json::Object me;
bool ok = Json::parse(response.body(), me, e);
#else
Json::Object me;
try {
me = (Json::Object)Json::Parser().parse(response.body());
}
catch (Json::ParseError pe) {
}
bool ok = me.isNull();
#endif
if (!ok) {
LOG_ERROR("could not parse JSON: '" << response.body() << "'");
setError(ERROR_MSG("badjson"));
authenticated().emit(Identity::Invalid);
}
else {
std::string id = me.get("id");
std::string email = me.get("emailAddress");
if (getUserProfileAsJson)
{
// In the Identity's name field more complete user info is passed in JSON format as returned from LinkedIn, see details at:
// https://developer.linkedin.com/docs/fields/basic-profile
authenticated().emit(Identity(service().name(), id, response.body(), email, true));
}
else
{
std::string name = me.get("firstName");
name += std::string(" ");
name += std::string(me.get("lastName"));
authenticated().emit(Identity(service().name(), id, name, email, true));
}
}
}
else {
if (!err) {
LOG_ERROR("user info request returned: " << response.status());
LOG_ERROR("with: " << response.body());
}
else {
LOG_ERROR("handleMe(): " << err.message());
}
setError(ERROR_MSG("badresponse"));
authenticated().emit(Identity::Invalid);
}
}
示例2: handleMe
void handleMe(boost::system::error_code err, const Http::Message& response)
{
#ifndef WT_TARGET_JAVA
WApplication::instance()->resumeRendering();
#endif
if (!err && response.status() == 200) {
#ifndef WT_TARGET_JAVA
Json::ParseError e;
Json::Object me;
bool ok = Json::parse(response.body(), me, e);
#else
Json::Object me;
try {
me = (Json::Object)Json::Parser().parse(response.body());
} catch (Json::ParseError pe) {
}
bool ok = me.isNull();
#endif
if (!ok) {
LOG_ERROR("could not parse Json: '" << response.body() << "'");
setError(ERROR_MSG("badjson"));
authenticated().emit(Identity::Invalid);
} else {
std::string id = me.get("id");
WT_USTRING userName = me.get("name");
std::string email = me.get("email").orIfNull("");
bool emailVerified = !me.get("email").isNull();
authenticated().emit(Identity(service().name(), id, userName,
email, emailVerified));
}
} else {
if (!err) {
LOG_ERROR("user info request returned: " << response.status());
LOG_ERROR("with: " << response.body());
} else
LOG_ERROR("handleMe(): " << err.message());
setError(ERROR_MSG("badresponse"));
authenticated().emit(Identity::Invalid);
}
}