How to recursively iterate the USTRUCT?

I want to get tree of USTRUCT object. This is reasonable to parse\save JSON objects.

I know, there are this (StaticStruct) method, but I don’t know anything about this:

	UScriptStruct* test = FMyStructType::StaticStruct();

Maybe it helps me, but I need to learn opinion of staff.
I also need to get\set values in from tree.

Use the methods in

and

to navigate the members.

Stop! But how can I iterate by the VALUES in tree?

You want to iterate over the members of a ustruct and extract the value of each member, correct?

You want to use FYourStruct::StaticClass() as the base. The first child property is the Children property of that struct. That’s a linked list of children, to the second property is Children->Next. The third is Children->Next->Next. Etc.

You want to cast these children to a UProperty object, see this:

https://docs.unrealengine.com/latest/INT/API/Runtime/CoreUObject/UObject/UProperty/index.html

It will be one of those 4 subclasses listed at the top. You then use one of the GetXPropertyValue( obj ) methods to get the value. E.g.

int IntValue = SomeIntegerProperty->GetIntegerPropertyValue( MyStructObject );

If you find a struct or class propery value, start a new tree.

Don’t forget they could be arrays.

The fields of struct is static. I can’t iterate by the fields like a dict in Python.
And while iterating, code don’t know anything about types. Casting void to specified “FStructType” is not good idea.

I’ll try this! Thanks for clarifying. I’ll let you know about the result :slight_smile:
And how to identify type of property?

FYourStruct::StaticClass() should be FYourStruct::StaticStruct()