UStruct to conversion with mapping name

Hey, I was toying around with the UStruct to and to UStruct converters, and I need to admit they’re pretty useful, but I have a question. In most usage cases, data from servers has other naming conventions. Imagine this:
Data from server:

{
  "test_string": "Hello World",
  "test_number": 1337,
  "test_bool": false
}

Now, in Unreal, I want to map it to a struct where the variables are named like this

FString TestString;
int TestNumber;
bool TestBool;

But the converters always try to translate it 1:1. My question now, is there a way to specify how the converters should map them? If not, it would be great to have a UPROPERTY specifier for it, like:

UPROPERTY(EditAnywhere, BlueprintReadWrite, JsonMapping = "test_string")
FString TestString

In the docs, something is maybe meant with this:

Converts from a Object to a UStruct, using importText

So where to specify this importText?

Thanks in advance!

It probably reference to that

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

Here you got converter code:

https://github.com/EpicGames/UnrealEngine/blob/76085d1106078d8988e4404391428252ba1eb9a7/Engine/Source/Runtime/JsonUtilities/Private/JsonObjectConverter.cpp

I don’t see any specifier checks, and if they would be it most likely would be meta specifier as only those don’t require UHT modification. You can read meta specifiers pretty easily via UField functions (since meta subspecies can be in UClass and UFunction)

This is not documented you would need to figure out looking via API refrence, but i quickly find example how to get UProperty of variable

Hey, thank you! I had a look and in line 182 the variable name is defined as FString VariableName = StandardizeCase(Property->GetName());. So it get’s just the variable name of that property and uses the StandardizeCase function which just puts the first char in lower case and replaces “ID” with “Id”, so that is probably where I’d need to add something. Maybe I’ll do a pull request for changing those mappings, it would be much easier to have that.

Yea if you feel up to it, do modification and pull request :slight_smile: You can always modify engine for your own use too

Made a Pull request here: https://github.com/EpicGames/UnrealEngine/pull/3569

Thank you! but Property->GetMetaData don’t work in the shipping build (ubt just isn’t compiling this). I think it’s just for editor only.