UE4_C++_自动解析Json

本文介绍如何在UE4中使用C++来自动解析JSON数据,首先需要在C++中定义相应的数据结构,然后通过添加特定标识符CustomStructureParam和防止UBT自动生成解析代码的CustomThunk,实现JSON数据的高效读取。
摘要由CSDN通过智能技术生成

//读取任意结构jSON数据
//需在C++中定义好相应数据结构
//蓝图定义数据结构后续考虑开发-----
/1、添加手工解析的标识符 CustomStructureParam
2、 阻止UBT不自动生成解析代码 CustomThunk
/

/**
//JsonOperateLibrary.h

* ReadJson 读取Json字符串,将其转换为任意C++定义的与Json字符串相对应的结构
*
*
* @param JsonStr Json字符串
* @param AnyStruct Json字符串结构,该结构需用C++定义
* 
*/
UFUNCTION(BlueprintCallable, Category = "Json", CustomThunk,meta = (CustomStructureParam = "AnyStruct"))
	static void ReadJson(const FString& JsonStr, UStructProperty* AnyStruct);


DECLARE_FUNCTION(execReadJson) {
	//获取函数输入参数
	P_GET_PROPERTY(UStrProperty, JsonStr);

	// Steps into the stack, walking to the next property in it
	Stack.Step(Stack.Object, NULL);

	// Grab the last property found when we walked the stack
	// This does not contains the property value, only its type information
	UStructProperty* StructProperty = ExactCast<UStructProperty>(Stack.MostRecentProperty);

	//
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值