Get UProperty of UStruct returns wrong value.

anonymous_user_d860badc
Sun, 05 Mar 2017 13:33:45 +0000
Editor Scripting

I am trying to access value from UStruct defined in UStruct

USTRUCT()
struct FJsonData
{
	GENERATED_USTRUCT_BODY()

	UPROPERTY()
	double prop= 0;
 };

I am using FJsonObjectConverter to convert string to this UStruct:

FJsonObjectConverter::JsonObjectStringToUStruct<FJsonData>(singleObjectString, &JsonData, 0, 0);

But when i am trying to get value of UPROPERTY prop, I am getting wrong values.
I am probably doing something wrong.

FString singleObjectString = StringData.Left( StringData.Find(TEXT("}"))+1);
FJsonData JsonData;
UE_LOG(LogTemp, Warning, TEXT("String received: %s "), *singleObjectString);

FJsonObjectConverter::JsonObjectStringToUStruct<FJsonData>(singleObjectString, &JsonData, 0, 0);

double prop= JsonData.prop;

UE_LOG(LogTemp, Warning, TEXT("prop: %d \n"), JsonData.prop);

or

UE_LOG(LogTemp, Warning, TEXT("prop: %d \n"), prop);

3 posts - 1 participant