How to deserialize a TArray to a UString

Hi,

In our project we need to pass some UStructs at the same time throw RPC functions, to do so, we serialize them into TArrays and finaly this arrays are stored in a bigger TArray which is send from the server to the client.
Until now we have been able to serialize an UStruct into to a TArray but we don’t now how to do the oposite operation (deserialize the content of the TArray into the corresponding UStruct).

Here there is an example:

FMyStruct myStruct;
myStruct.id32 = 77;

FBufferArchive Buffer(true);
FMyStruct::StaticStruct()->SerializeBin(Buffer, &myStruct);

TArray Bytes = Buffer;

How can we deserialize this “Bytes” TArray?

Thank you very much.

Hi Luis,

You just call SerializeBin again, but with a reader archive:

FMemoryReader Reader(Bytes);
FMyStruct::StaticStruct()->SerializeBin(Reader, &myStruct);

Hope this helps,

Steve

Thank you very much, that was very useful.