本文整理汇总了C++中JsonWriter::WriteObjectStart方法的典型用法代码示例。如果您正苦于以下问题:C++ JsonWriter::WriteObjectStart方法的具体用法?C++ JsonWriter::WriteObjectStart怎么用?C++ JsonWriter::WriteObjectStart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonWriter
的用法示例。
在下文中一共展示了JsonWriter::WriteObjectStart方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeRegionEnumJSON
void PlayFab::MatchmakerModels::FRegisterGameRequest::writeJSON(JsonWriter& writer) const
{
writer->WriteObjectStart();
writer->WriteIdentifierPrefix(TEXT("ServerHost")); writer->WriteValue(ServerHost);
writer->WriteIdentifierPrefix(TEXT("ServerPort")); writer->WriteValue(ServerPort);
writer->WriteIdentifierPrefix(TEXT("Build")); writer->WriteValue(Build);
writer->WriteIdentifierPrefix(TEXT("Region")); writeRegionEnumJSON(pfRegion, writer);
writer->WriteIdentifierPrefix(TEXT("GameMode")); writer->WriteValue(GameMode);
if(Tags.Num() != 0)
{
writer->WriteObjectStart(TEXT("Tags"));
for (TMap<FString, FString>::TConstIterator It(Tags); It; ++It)
{
writer->WriteIdentifierPrefix((*It).Key);
writer->WriteValue((*It).Value);
}
writer->WriteObjectEnd();
}
writer->WriteObjectEnd();
}
示例2:
void PlayFab::MatchmakerModels::FItemInstance::writeJSON(JsonWriter& writer) const
{
writer->WriteObjectStart();
if(ItemId.IsEmpty() == false) { writer->WriteIdentifierPrefix(TEXT("ItemId")); writer->WriteValue(ItemId); }
if(ItemInstanceId.IsEmpty() == false) { writer->WriteIdentifierPrefix(TEXT("ItemInstanceId")); writer->WriteValue(ItemInstanceId); }
if(ItemClass.IsEmpty() == false) { writer->WriteIdentifierPrefix(TEXT("ItemClass")); writer->WriteValue(ItemClass); }
if(PurchaseDate.notNull()) { writer->WriteIdentifierPrefix(TEXT("PurchaseDate")); writeDatetime(PurchaseDate, writer); }
if(Expiration.notNull()) { writer->WriteIdentifierPrefix(TEXT("Expiration")); writeDatetime(Expiration, writer); }
if(RemainingUses.notNull()) { writer->WriteIdentifierPrefix(TEXT("RemainingUses")); writer->WriteValue(RemainingUses); }
if(UsesIncrementedBy.notNull()) { writer->WriteIdentifierPrefix(TEXT("UsesIncrementedBy")); writer->WriteValue(UsesIncrementedBy); }
if(Annotation.IsEmpty() == false) { writer->WriteIdentifierPrefix(TEXT("Annotation")); writer->WriteValue(Annotation); }
if(CatalogVersion.IsEmpty() == false) { writer->WriteIdentifierPrefix(TEXT("CatalogVersion")); writer->WriteValue(CatalogVersion); }
if(BundleParent.IsEmpty() == false) { writer->WriteIdentifierPrefix(TEXT("BundleParent")); writer->WriteValue(BundleParent); }
if(DisplayName.IsEmpty() == false) { writer->WriteIdentifierPrefix(TEXT("DisplayName")); writer->WriteValue(DisplayName); }
if(UnitCurrency.IsEmpty() == false) { writer->WriteIdentifierPrefix(TEXT("UnitCurrency")); writer->WriteValue(UnitCurrency); }
writer->WriteIdentifierPrefix(TEXT("UnitPrice")); writer->WriteValue(static_cast<int64>(UnitPrice));
if(BundleContents.Num() != 0)
{
writer->WriteArrayStart(TEXT("BundleContents"));
for (const FString& item : BundleContents)
{
writer->WriteValue(item);
}
writer->WriteArrayEnd();
}
if(CustomData.Num() != 0)
{
writer->WriteObjectStart(TEXT("CustomData"));
for (TMap<FString, FString>::TConstIterator It(CustomData); It; ++It)
{
writer->WriteIdentifierPrefix((*It).Key);
writer->WriteValue((*It).Value);
}
writer->WriteObjectEnd();
}
writer->WriteObjectEnd();
}
示例3: CopyJsonValueToWriter
void CopyJsonValueToWriter( JsonWriter &Json, const FString& ValueName, const TSharedPtr<FJsonValue>& JsonValue )
{
if ( JsonValue->Type == EJson::String )
{
Json->WriteValue( ValueName, JsonValue->AsString() );
}
else if ( JsonValue->Type == EJson::Array )
{
if (ValueName.IsEmpty())
{
Json->WriteArrayStart();
}
else
{
Json->WriteArrayStart(ValueName);
}
const TArray<TSharedPtr<FJsonValue>>& Array = JsonValue->AsArray();
for ( const auto& ArrayValue : Array )
{
CopyJsonValueToWriter(Json, FString(), ArrayValue);
}
Json->WriteArrayEnd();
}
else if ( JsonValue->Type == EJson::Object )
{
if (ValueName.IsEmpty())
{
Json->WriteObjectStart();
}
else
{
Json->WriteObjectStart(ValueName);
}
const TSharedPtr<FJsonObject>& Object = JsonValue->AsObject();
for ( const auto& ObjectProperty : Object->Values)
{
CopyJsonValueToWriter(Json, ObjectProperty.Key, ObjectProperty.Value );
}
Json->WriteObjectEnd();
}
else
{
UE_LOG(LogChunkManifestGenerator, Warning, TEXT("Unrecognized json value type %d in object %s"), *UEnum::GetValueAsString(TEXT("Json.EJson"), JsonValue->Type), *ValueName)
}
}
示例4: writeDatetime
void PlayFab::MatchmakerModels::FVirtualCurrencyRechargeTime::writeJSON(JsonWriter& writer) const
{
writer->WriteObjectStart();
writer->WriteIdentifierPrefix(TEXT("SecondsToRecharge")); writer->WriteValue(SecondsToRecharge);
writer->WriteIdentifierPrefix(TEXT("RechargeTime")); writeDatetime(RechargeTime, writer);
writer->WriteIdentifierPrefix(TEXT("RechargeMax")); writer->WriteValue(RechargeMax);
writer->WriteObjectEnd();
}
示例5: SaveCookedPackageAssetRegistry
// cooked package asset registry saves information about all the cooked packages and assets contained within for stats purposes
// in json format
bool FChunkManifestGenerator::SaveCookedPackageAssetRegistry( const FString& SandboxCookedRegistryFilename, const bool Append )
{
bool bSuccess = false;
for ( const auto& Platform : Platforms )
{
TSet<FName> CookedPackages;
// save the file
const FString CookedAssetRegistryFilename = SandboxCookedRegistryFilename.Replace(TEXT("[Platform]"), *Platform->PlatformName());
FString JsonOutString;
JsonWriter Json = TJsonWriterFactory<TCHAR, TPrettyJsonPrintPolicy<TCHAR> >::Create(&JsonOutString);
Json->WriteObjectStart();
Json->WriteArrayStart(TEXT("Packages"));
for ( const auto& Package : AllCookedPackages )
{
Json->WriteObjectStart(); // unnamed package start
const FName& PackageName = Package.Key;
const FString& SandboxPath = Package.Value;
CookedPackages.Add( PackageName );
FString PlatformSandboxPath = SandboxPath.Replace(TEXT("[Platform]"), *Platform->PlatformName());
FDateTime TimeStamp = IFileManager::Get().GetTimeStamp( *PlatformSandboxPath );
Json->WriteValue( "SourcePackageName", PackageName.ToString() );
Json->WriteValue( "CookedPackageName", PlatformSandboxPath );
Json->WriteValue( "CookedPackageTimeStamp", TimeStamp.ToString() );
Json->WriteArrayStart("AssetData");
for (const auto& AssetData : AssetRegistryData)
{ // Add only assets that have actually been cooked and belong to any chunk
if (AssetData.ChunkIDs.Num() > 0 && (AssetData.PackageName == PackageName))
{
Json->WriteObjectStart();
// save all their infos
Json->WriteValue(TEXT("ObjectPath"), AssetData.ObjectPath.ToString() );
Json->WriteValue(TEXT("PackageName"), AssetData.PackageName.ToString() );
Json->WriteValue(TEXT("PackagePath"), AssetData.PackagePath.ToString() );
Json->WriteValue(TEXT("GroupNames"), AssetData.GroupNames.ToString() );
Json->WriteValue(TEXT("AssetName"), AssetData.AssetName.ToString() );
Json->WriteValue(TEXT("AssetClass"), AssetData.AssetClass.ToString() );
Json->WriteObjectStart("TagsAndValues");
for ( const auto& Tag : AssetData.TagsAndValues )
{
Json->WriteValue( Tag.Key.ToString(), Tag.Value );
}
Json->WriteObjectEnd(); // end tags and values object
Json->WriteObjectEnd(); // end unnamed array object
}
}
Json->WriteArrayEnd();
Json->WriteObjectEnd(); // unnamed package
}
if ( Append )
{
FString JsonInString;
if ( FFileHelper::LoadFileToString(JsonInString, *CookedAssetRegistryFilename) )
{
// load up previous package asset registry and fill in any packages which weren't recooked on this run
JsonReader Reader = TJsonReaderFactory<TCHAR>::Create(JsonInString);
TSharedPtr<FJsonObject> JsonObject;
bool shouldRead = FJsonSerializer::Deserialize(Reader, JsonObject) && JsonObject.IsValid() && JsonObject->HasTypedField<EJson::Array>(TEXT("Packages"));
if ( shouldRead )
{
TArray<TSharedPtr<FJsonValue>> PackageList = JsonObject->GetArrayField(TEXT("Packages"));
for (auto PackageListIt = PackageList.CreateConstIterator(); PackageListIt && shouldRead; ++PackageListIt)
{
const TSharedPtr<FJsonValue>& JsonValue = *PackageListIt;
shouldRead = JsonValue->Type == EJson::Object;
if ( shouldRead )
{
const TSharedPtr<FJsonObject>& JsonPackage = JsonValue->AsObject();
// get the package name and see if we have already written it out this run
FString CookedPackageName;
verify( JsonPackage->TryGetStringField(TEXT("SourcePackageName"), CookedPackageName) );
const FName CookedPackageFName(*CookedPackageName);
if ( CookedPackages.Contains(CookedPackageFName))
{
// don't need to process this package
continue;
}
// check that the on disk version is still valid
FString SourcePackageName;
check( JsonPackage->TryGetStringField( TEXT("SourcePackageName"), SourcePackageName) );
// if our timestamp is different then don't copy the information over
FDateTime CurrentTimeStamp = IFileManager::Get().GetTimeStamp( *CookedPackageName );
//.........这里部分代码省略.........