本文整理汇总了C++中json::Value::isObject方法的典型用法代码示例。如果您正苦于以下问题:C++ Value::isObject方法的具体用法?C++ Value::isObject怎么用?C++ Value::isObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类json::Value
的用法示例。
在下文中一共展示了Value::isObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runtime_error
// Create the animation object from json
Animation::Animation(const Json::Value& value)
: length(-numeric_limits<float>::infinity())
{
// We first need to validate that this a Json object
if(!value.isObject())
{
throw std::runtime_error("Animation::Animation(const Json::Value& value) - value must be a object");
}
// Store the name of the animation
id = value["id"].asString();
// We need to iterate through the bones array
const Json::Value& bones = value["bones"];
// Process the bones
for(Json::Value::const_iterator bIt = bones.begin(); bIt != bones.end(); bIt++)
{
// Get the name of the bone we are exploring
std::string boneName = (*bIt)["boneId"].asString();
// Create a vector for the keyframe
std::vector<Keyframe *> keyframes;
// Iterate through the keyframes
const Json::Value& serializedKeyframes = (*bIt)["keyframes"];
// Process the keyframes
for(Json::Value::const_iterator kIt = serializedKeyframes.begin(); kIt != serializedKeyframes.end(); kIt++)
{
// Allocate a keyframe object from the serialized keyframe
Keyframe *keyframe = new Keyframe(*kIt);
// Store this keyframe in the vector
keyframes.push_back(keyframe);
}
// Decide the length of the animation
length = keyframes[keyframes.size() - 1]->keytime - keyframes[0]->keytime;
// Store this bone
boneKeyframes[boneName] = keyframes;
}
}
示例2: GetPortVlansId
TEST_F(GetPortVlansIdTest, PositiveExecute) {
network::json::GetPortVlansId command_json;
GetPortVlansId* command = new GetPortVlansId(TEST_UUID, TEST_PORT_ID);
EXPECT_NO_THROW(command_json.set_command(command));
Json::Value params;
Json::Value result;
params[COMPONENT] = TEST_UUID;
params[PORT_IDENTIFIER] = TEST_PORT_ID;
EXPECT_NO_THROW(command_json.method(params, result));
ASSERT_TRUE(result.isObject());
for (std::uint32_t i = 0; i < 10; ++i) {
ASSERT_EQ(result[VLAN_IDENTIFIERS][i][ID].asString(), std::to_string(i));
}
}
示例3: fromJson
bool Settings::fromJson(const Json::Value &json) {
if (!json.isObject())
return false;
m_json = json;
for (const auto & key: json.getMemberNames()) {
if (json[key].isObject()) {
//setJson(key, json[key]); // save type info
auto s = new Settings;
s->fromJson(json[key]);
setGroup(key, s);
} else if (json[key].isArray()) {
//setJson(key, json[key]);
} else {
set(key, json[key].asString());
m_json.removeMember(key); // todo: remove
}
}
return true;
}
示例4: ParseAudioMessageAttach
bool Talk::ParseAudioMessageAttach(const IMMessage& msg, IMAudio& audio)
{
if (msg.type_ != kNIMMessageTypeAudio)
return false;
Json::Value values;
Json::Reader reader;
if (reader.parse(msg.attach_, values) && values.isObject())
{
audio.display_name_ = values[kNIMAudioMsgKeyDisplayName].asString();
audio.file_extension_ = values[kNIMAudioMsgKeyExt].asString();
audio.md5_ = values[kNIMAudioMsgKeyMd5].asString();
audio.size_ = values[kNIMAudioMsgKeySize].asUInt64();
audio.url_ = values[kNIMAudioMsgKeyUrl].asString();
audio.duration_ = values[kNIMAudioMsgKeyDuration].asUInt();
return true;
}
return false;
}
示例5: CallbackLogin
static void CallbackLogin(const char* json_res, const void *callback)
{
if (callback != nullptr)
{
LoginRes res;
Json::Value values;
Json::Reader reader;
if (reader.parse(PCharToString(json_res), values) && values.isObject())
{
res.res_code_ = (NIMResCode)values[kNIMResCode].asInt();
res.login_step_ = (NIMLoginStep)values[kNIMLoginStep].asUInt();
res.relogin_ = values[kNIMRelogin].asBool();
res.retrying_ = values[kNIMRetrying].asBool();
ParseOtherClientsPres(values[kNIMOtherClientsPres], res.other_clients_);
}
Client::LoginCallback *cb = (Client::LoginCallback *)callback;
(*cb)(res);
}
}
示例6: handleObject
Json::Value JsonRpcPrivate::handleObject(Json::Value const & jsonObject) {
Json::Value response;
if (!jsonObject.isObject()) {
Json::Value const null;
response = invalidRequest(null);
} else {
Json::Value const id(jsonObject["id"]); //TODO: handle special responses (e.g. parse errors)
if (isRequest(jsonObject)) {
response = handleRequest(jsonObject, id);
} else if (isResponse(jsonObject)) {
Json::Value const null;
response = null;
handleResponse(jsonObject, id);
} else {
response = invalidRequest(id);
}
}
return response;
}
示例7: ParseFriendsProfile
bool ParseFriendsProfile(const std::string& friends_profile_json, std::list<FriendProfile>& profiles)
{
Json::Value values;
Json::Reader reader;
if (reader.parse(friends_profile_json, values) && values.isObject() && values[kNIMFriendKey].isArray())
{
Json::Value friends = values[kNIMFriendKey];
int len = friends.size();
for (int i = 0; i < len; i++)
{
FriendProfile profile;
ParseFriendProfile(friends[i], profile);
profiles.push_back(profile);
}
return true;
}
return false;
}
示例8: getClientSubFlowId
CString CPeraPDWeb::getClientSubFlowId( void )
{
ZTools::WriteZToolsFormatLog("CPeraPDWeb::getClientSubFlowId begin >>>>> %s"
, "\r\n" );
CWebMethodParamData * pParam = NULL;
CWebMethodData wmd;
//
wmd.m_sMethodName = "getClientSubFlowId";
//
if ( !InvokeJsMethod( &wmd ) )
{
ZTools::WriteZToolsFormatLog("调用 js 方法 getClientSubFlowId 失败 %s"
, "\r\n" );
return "";
}
ZTools::WriteZToolsFormatLog("调用 js 方法 getClientSubFlowId 返回 %s\r\n"
, wmd.m_sResult );
Json::Reader reader;
Json::Value obj;
try
{
if (!reader.parse((char*)(LPCTSTR) wmd.m_sResult, obj, false)) return "";
if (!obj.isObject()) return "";
CString sFlowId = ( obj["flowId"].isString() ) ? obj["flowId"].asCString() : _T("");
CString sOptMsg = ( obj["optMsg "].isString() ) ? obj["optMsg "].asCString() : _T("");
if ( !sOptMsg.IsEmpty() || sFlowId.IsEmpty() ) return "";
return sFlowId;
}
catch (...)
{
return "";
}
ZTools::WriteZToolsFormatLog("CPeraPDWeb::getClientSubFlowId end <<<<<< %s"
, "\r\n" );
return "";
}
示例9: CallKeepTicket
CString CallKeepTicket(CString sTicket)
{
CString sReturn;
CString sTicketValue;
int nPos = sTicket.Find('=');
if (nPos == -1)
{
return sReturn;
}
else
{
sTicketValue = sTicket.Right(sTicket.GetLength() - sTicket.Find('=') - 1);
}
CString sResult = KeepTicket(sTicketValue);
Json::Value jRoot;
Json::Reader reader;
if (!reader.parse((LPCTSTR)sResult, jRoot))
{
return sReturn;
}
if (!jRoot.isObject()) return sReturn;
CString sMsg;
CString sTime;
sMsg = ( jRoot["result"].isString() ) ? jRoot["result"].asCString() : _T("");
sTime = ( jRoot["maxInactiveInterval"].isString() ) ? jRoot["maxInactiveInterval"].asCString() : _T("");
int nTime = atoi(sTime);
if (nTime > 0)
{
nTime *= 40000;
}
if (nTime > 0)
{
s_nNextCallTime = nTime;
}
sReturn = sMsg;
return sReturn;
}
示例10: CreateDicom
static void CreateDicom(RestApiPostCall& call)
{
// curl http://localhost:8042/tools/create-dicom -X POST -d '{"PatientName":"Hello^World"}'
// curl http://localhost:8042/tools/create-dicom -X POST -d '{"PatientName":"Hello^World","PixelData":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gUGDDcB53FulQAAAElJREFUGNNtj0sSAEEEQ1+U+185s1CtmRkblQ9CZldsKHJDk6DLGLJa6chjh0ooQmpjXMM86zPwydGEj6Ed/UGykkEM8X+p3u8/8LcOJIWLGeMAAAAASUVORK5CYII="}'
Json::Value replacements;
if (call.ParseJsonRequest(replacements) && replacements.isObject())
{
ParsedDicomFile dicom;
Json::Value::Members members = replacements.getMemberNames();
for (size_t i = 0; i < members.size(); i++)
{
const std::string& name = members[i];
std::string value = replacements[name].asString();
DicomTag tag = FromDcmtkBridge::ParseTag(name);
if (tag == DICOM_TAG_PIXEL_DATA)
{
dicom.EmbedImage(value);
}
else
{
dicom.Replace(tag, value);
}
}
DicomInstanceToStore toStore;
toStore.SetParsedDicomFile(dicom);
std::string id;
StoreStatus status = OrthancRestApi::GetContext(call).Store(id, toStore);
if (status == StoreStatus_Failure)
{
LOG(ERROR) << "Error while storing a manually-created instance";
return;
}
OrthancRestApi::GetApi(call).AnswerStoredInstance(call, id, status);
}
}
示例11: WomanListAdvertCallbackHandle
void RequestAdvertController::WomanListAdvertCallbackHandle(long requestId, const string& url, bool requestRet, const char* buf, int size)
{
AdWomanListAdvertItem item;
string errnum = "";
string errmsg = "";
bool bFlag = false;
if (requestRet) {
// request success
Json::Value dataJson;
if( HandleResult(buf, size, errnum, errmsg, &dataJson) ) {
if (dataJson.isObject()) {
bFlag = item.Parsing(dataJson);
}
if (!bFlag) {
// parsing fail
errnum = LOCAL_ERROR_CODE_PARSEFAIL;
errmsg = LOCAL_ERROR_CODE_PARSEFAIL_DESC;
FileLog("httprequest", "RequestAdvertController::WomanListAdvertCallbackHandle() parsing fail:"
"(url:%s, size:%d, buf:%s)",
url.c_str(), size, buf);
}
}
}
else {
// request fail
errnum = LOCAL_ERROR_CODE_TIMEOUT;
errmsg = LOCAL_ERROR_CODE_TIMEOUT_DESC;
}
if( m_Callback.onRequestAdWomanListAdvert != NULL ) {
// item.advertId = "advertId";
// item.image = "image";
// item.height = 15;
// item.width = 12;
// item.adurl = "adurl";
// item.openType = AD_OT_SYSTEMBROWER;
m_Callback.onRequestAdWomanListAdvert(requestId, bFlag, errnum, errmsg, item);
}
}
示例12: parseJsonMessage
Message MessagesClient::parseJsonMessage(const Json::Value &json)
{
if (!json.isObject())
{
throw ProtocolError("Malformed JSON document (object expected)");
}
Message msg;
msg.id = CheckedConverter::toUint32(json["id"]);
msg.lastModified = CheckedConverter::toUint64(json["lastModified"]);
msg.deleted = CheckedConverter::toBool(json["deleted"]);
if (!msg.deleted)
{
msg.dateReceived = CheckedConverter::toDateTime(json["dateReceived"]);
msg.keySafe = CheckedConverter::toVector(json["keySafe"]);
msg.content = CheckedConverter::toVector(json["content"]);
}
msg.meta = CheckedConverter::toVector(json["meta"], AllowEmpty::True);
msg.hasAttachments = CheckedConverter::toBool(json["hasAttachments"]);
return msg;
}
示例13: fromJSON
bool OnTBTClientStateMarshaller::fromJSON(const Json::Value& json,OnTBTClientState& c)
{
try
{
if(!json.isObject()) return false;
if(!json.isMember("state")) return false;
{
const Json::Value& j=json["state"];
if(!TBTStateMarshaller::fromJSON(j,c.state))
return false;
}
}
catch(...)
{
return false;
}
return checkIntegrity(c);
}
示例14: ParseSysMessages
bool ParseSysMessages(const std::string& sysmsgs_json, std::list<SysMessage>& msgs, int* unread)
{
Json::Value values;
Json::Reader reader;
if (reader.parse(sysmsgs_json, values) && values.isObject())
{
*unread = values[kNIMSysMsglogQueryKeyUnreadCount].asUInt();
Json::Value content = values[kNIMSysMsglogQueryKeyContent];
int len = content.size();
for (int i = 0; i < len; i++)
{
SysMessage msg;
ParseSysMessageContent(content[i], msg);
msgs.push_back(msg);
}
return true;
}
return false;
}
示例15: fromJSON
bool DialNumber_requestMarshaller::fromJSON(const Json::Value& json,DialNumber_request& c)
{
try
{
if(!json.isObject()) return false;
if(!json.isMember("number")) return false;
{
const Json::Value& j=json["number"];
if(!j.isString()) return false;
c.number=j.asString();
}
}
catch(...)
{
return false;
}
return checkIntegrity(c);
}