Write Large UStruct to a Single String

In the editor, you can copy an entire data structure to a single string, and paste it into a new one. It’s very handy, but let’s say I want to generate that data ingame and write that same string to a file so I can copy it and store it in the editor.

Can this be done?

I don’t want to write the struct to JSON, I want that properly formatted string you get in the editor.

Thank you.

1 Like

I figured it out, the following gave me what I wanted:

UScriptStruct* Struct = Data.StaticStruct();
FString Output = TEXT("");
Struct->ExportText(Output, &Data, nullptr, this, (PPF_ExportsNotFullyQualified | PPF_Copy | PPF_Delimited | PPF_IncludeTransient), nullptr);

Sounds like you are describing Serialization:

A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums,Read%26_Write_Any_Data_to_Compressed_Binary_Files

Hello. Do you have a snippet you can share, to convert from String back to Struct? Somehow, I can’t manage to make UScriptStruct::ImportText to compile.

Add ApplicationCore to your PublicDependencyModuleNames in [Project].Build.cs.