Unreal : 读取json 文件

1.在Build.cs 中 添加 "Json","JsonUtilities"

例如 PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore","Json","JsonUtilities" });

2.在文件中引入 

#include "Runtime/JsonUtilities/Public/JsonObjectConverter.h"
void AMyActor::ReadFileTest(FString path) {
	FString FullPath = FPaths::ProjectDir();
	FullPath += path;
	print(FullPath);
	FString jsonStr;
	FFileHelper::LoadFileToString(jsonStr, *FullPath);
	print(jsonStr);
	
	FJsonObjectConverter::JsonObjectStringToUStruct(jsonStr, &person, 0, 0);
	UE_LOG(LogTemp, Warning, TEXT("name:%s"),*person.Name);
}

你可能感兴趣的:(Unreal,unreal)