本文整理汇总了C++中JsonValue::GetObject方法的典型用法代码示例。如果您正苦于以下问题:C++ JsonValue::GetObject方法的具体用法?C++ JsonValue::GetObject怎么用?C++ JsonValue::GetObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonValue
的用法示例。
在下文中一共展示了JsonValue::GetObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: identityFile
TEST(PersistentCognitoIdentityProvider_JsonImpl_Test, TestPersistance)
{
JsonValue someOtherIdentityPool;
someOtherIdentityPool.WithString("IdentityId", "SomeOtherIdentity");
JsonValue identityDoc;
identityDoc.WithObject("SomeOtherIdentityPool", someOtherIdentityPool);
Aws::String filePath = ComputeIdentityFilePath();
FileSystemUtils::RemoveFileIfExists(filePath.c_str());
std::ofstream identityFile(filePath.c_str());
identityFile << identityDoc.WriteReadable();
identityFile.close();
Aws::Map<Aws::String, LoginAccessTokens> loginsMap;
LoginAccessTokens loginAccessTokens;
loginAccessTokens.accessToken = "LoginValue";
loginAccessTokens.longTermTokenExpiry = 1001;
loginAccessTokens.longTermToken = "LongTermToken";
loginsMap["LoginName"] = loginAccessTokens;
//scope it to kill the cache and force it to reload from file.
{
PersistentCognitoIdentityProvider_JsonFileImpl identityProvider("IdentityPoolWeWant", "accountId", filePath.c_str());
EXPECT_FALSE(identityProvider.HasIdentityId());
EXPECT_FALSE(identityProvider.HasLogins());
identityProvider.PersistIdentityId("IdentityWeWant");
identityProvider.PersistLogins(loginsMap);
}
PersistentCognitoIdentityProvider_JsonFileImpl identityProvider("IdentityPoolWeWant", "accountId", filePath.c_str());
EXPECT_EQ("IdentityWeWant", identityProvider.GetIdentityId());
EXPECT_EQ("LoginName", identityProvider.GetLogins().begin()->first);
EXPECT_EQ(loginAccessTokens.accessToken, identityProvider.GetLogins().begin()->second.accessToken);
EXPECT_EQ(loginAccessTokens.longTermToken, identityProvider.GetLogins().begin()->second.longTermToken);
EXPECT_EQ(loginAccessTokens.longTermTokenExpiry, identityProvider.GetLogins().begin()->second.longTermTokenExpiry);
std::ifstream identityFileInput(filePath.c_str());
JsonValue finalIdentityDoc(identityFileInput);
identityFileInput.close();
FileSystemUtils::RemoveFileIfExists(filePath.c_str());
ASSERT_TRUE(finalIdentityDoc.ValueExists("SomeOtherIdentityPool"));
ASSERT_TRUE(finalIdentityDoc.ValueExists("IdentityPoolWeWant"));
JsonValue ourIdentityPool = finalIdentityDoc.GetObject("IdentityPoolWeWant");
ASSERT_EQ("IdentityWeWant", ourIdentityPool.GetString("IdentityId"));
ASSERT_EQ("LoginName", ourIdentityPool.GetObject("Logins").GetAllObjects().begin()->first);
ASSERT_EQ(loginAccessTokens.accessToken, ourIdentityPool.GetObject("Logins").GetAllObjects().begin()->second.GetString("AccessToken"));
ASSERT_EQ(loginAccessTokens.longTermToken, ourIdentityPool.GetObject("Logins").GetAllObjects().begin()->second.GetString("LongTermToken"));
ASSERT_EQ(loginAccessTokens.longTermTokenExpiry, ourIdentityPool.GetObject("Logins").GetAllObjects().begin()->second.GetInt64("Expiry"));
}
开发者ID:fabregaszy,项目名称:aws-sdk-cpp,代码行数:54,代码来源:PersistentCognitoIdentityProvider_JsonFileImplTest.cpp
示例2:
AttributeValueMap::AttributeValueMap(const JsonValue& jsonValue)
{
const Aws::Map<Aws::String, JsonValue> map = jsonValue.GetObject("M").GetAllObjects();
for (auto& item : map)
{
std::shared_ptr<AttributeValue> attributeValue = Aws::MakeShared<AttributeValue>("AttributeValue");
JsonValue itemValue = item.second;
*attributeValue = itemValue;
m_m.insert(m_m.begin(), std::pair<Aws::String, const std::shared_ptr<AttributeValue>>(item.first, attributeValue));
}
}