engine
 
载入中...
搜索中...
未找到
Public 成员函数 | 静态 Public 成员函数 | 所有成员列表
FJsonObjectConverter类 参考

Class that handles converting Json objects to and from UStructs 更多...

#include <JsonObjectConverter.h>

Public 成员函数

 DECLARE_DELEGATE_RetVal_TwoParams (TSharedPtr< FJsonValue >, CustomExportCallback, FProperty *, const void *)
 Optional callback that will be run when exporting a single property to Json. 更多...
 

静态 Public 成员函数

static bool GetTextFromField (const FString &FieldName, const TSharedPtr< FJsonValue > &FieldValue, FText &TextOut)
 Convert a Json value to text (takes some hints from the value name)
 
static bool GetTextFromObject (const TSharedRef< FJsonObject > &Obj, FText &TextOut)
 Parse an FText from a json object (assumed to be of the form where keys are culture codes and values are strings)
 
template<typename OutStructType >
static bool JsonArrayStringToUStruct (const FString &JsonString, TArray< OutStructType > *OutStructArray, int64 CheckFlags, int64 SkipFlags)
 Converts from a json string containing an array to an array of UStructs 更多...
 
template<typename OutStructType >
static bool JsonArrayToUStruct (const TArray< TSharedPtr< FJsonValue > > &JsonArray, TArray< OutStructType > *OutStructArray, int64 CheckFlags, int64 SkipFlags)
 Converts from an array of json values to an array of UStructs. 更多...
 
static bool JsonAttributesToUStruct (const TMap< FString, TSharedPtr< FJsonValue > > &JsonAttributes, const UStruct *StructDefinition, void *OutStruct, int64 CheckFlags, int64 SkipFlags)
 Converts a set of json attributes (possibly from within a JsonObject) to a UStruct, using importText 更多...
 
template<typename OutStructType >
static bool JsonObjectStringToUStruct (const FString &JsonString, OutStructType *OutStruct, int64 CheckFlags, int64 SkipFlags)
 Converts from a json string containing an object to a UStruct 更多...
 
static bool JsonObjectToUStruct (const TSharedRef< FJsonObject > &JsonObject, const UStruct *StructDefinition, void *OutStruct, int64 CheckFlags=0, int64 SkipFlags=0)
 Converts from a Json Object to a UStruct, using importText 更多...
 
template<typename OutStructType >
static bool JsonObjectToUStruct (const TSharedRef< FJsonObject > &JsonObject, OutStructType *OutStruct, int64 CheckFlags=0, int64 SkipFlags=0)
 Templated version of JsonObjectToUStruct 更多...
 
static bool JsonValueToUProperty (const TSharedPtr< FJsonValue > &JsonValue, FProperty *Property, void *OutValue, int64 CheckFlags, int64 SkipFlags)
 Converts a single JsonValue to the corresponding FProperty (this may recurse if the property is a UStruct for instance). 更多...
 
static TSharedPtr< FJsonValue > ObjectJsonCallback (FProperty *Property, const void *Value)
 Utility Export Callback for having object properties expanded to full Json.
 
static FString StandardizeCase (const FString &StringIn)
 FName case insensitivity can make the casing of UPROPERTIES unpredictable. 更多...
 
template<typename CharType , template< typename > class PrintPolicy>
static bool UStructToFormattedJsonObjectString (const UStruct *StructDefinition, const void *Struct, FString &OutJsonString, int64 CheckFlags, int64 SkipFlags, int32 Indent=0, const CustomExportCallback *ExportCb=nullptr)
 Wrapper to UStructToJsonObjectString that allows a print policy to be specified.
 
static bool UStructToJsonAttributes (const UStruct *StructDefinition, const void *Struct, TMap< FString, TSharedPtr< FJsonValue > > &OutJsonAttributes, int64 CheckFlags, int64 SkipFlags, const CustomExportCallback *ExportCb=nullptr)
 Converts from a UStruct to a set of json attributes (possibly from within a JsonObject) 更多...
 
template<typename InStructType >
static TSharedPtr< FJsonObject > UStructToJsonObject (const InStructType &InStruct, int64 CheckFlags=0, int64 SkipFlags=0, const CustomExportCallback *ExportCb=nullptr)
 Templated version of UStructToJsonObject to try and make most of the params. 更多...
 
static bool UStructToJsonObject (const UStruct *StructDefinition, const void *Struct, TSharedRef< FJsonObject > OutJsonObject, int64 CheckFlags, int64 SkipFlags, const CustomExportCallback *ExportCb=nullptr)
 Converts from a UStruct to a Json Object, using exportText 更多...
 
template<typename InStructType >
static bool UStructToJsonObjectString (const InStructType &InStruct, FString &OutJsonString, int64 CheckFlags=0, int64 SkipFlags=0, int32 Indent=0, const CustomExportCallback *ExportCb=nullptr, bool bPrettyPrint=true)
 Templated version; Converts from a UStruct to a json string containing an object, using exportText 更多...
 
static bool UStructToJsonObjectString (const UStruct *StructDefinition, const void *Struct, FString &OutJsonString, int64 CheckFlags, int64 SkipFlags, int32 Indent=0, const CustomExportCallback *ExportCb=nullptr, bool bPrettyPrint=true)
 Converts from a UStruct to a json string containing an object, using exportText 更多...
 

详细描述

Class that handles converting Json objects to and from UStructs

成员函数说明

◆ DECLARE_DELEGATE_RetVal_TwoParams()

FJsonObjectConverter::DECLARE_DELEGATE_RetVal_TwoParams ( TSharedPtr< FJsonValue >  ,
CustomExportCallback  ,
FProperty *  ,
const void *   
)

Optional callback that will be run when exporting a single property to Json.

If this returns a valid value it will be inserted into the export chain. If this returns nullptr or is not bound, it will try generic type-specific export behavior before falling back to outputting ExportText as a string.

◆ JsonArrayStringToUStruct()

template<typename OutStructType >
static bool FJsonObjectConverter::JsonArrayStringToUStruct ( const FString &  JsonString,
TArray< OutStructType > *  OutStructArray,
int64  CheckFlags,
int64  SkipFlags 
)
inlinestatic

Converts from a json string containing an array to an array of UStructs

参数
JsonStringString containing JSON formatted data.
OutStructArrayThe UStruct array to copy in to
CheckFlagsOnly convert properties that match at least one of these flags. If 0 check all properties.
SkipFlagsSkip properties that match any of these flags.
返回
False if any properties matched but failed to deserialize.

◆ JsonArrayToUStruct()

template<typename OutStructType >
static bool FJsonObjectConverter::JsonArrayToUStruct ( const TArray< TSharedPtr< FJsonValue > > &  JsonArray,
TArray< OutStructType > *  OutStructArray,
int64  CheckFlags,
int64  SkipFlags 
)
inlinestatic

Converts from an array of json values to an array of UStructs.

参数
JsonArrayArray containing json values to convert.
OutStructArrayThe UStruct array to copy in to
CheckFlagsOnly convert properties that match at least one of these flags. If 0 check all properties.
SkipFlagsSkip properties that match any of these flags.
返回
False if any of the matching elements are not an object, or if one of the matching elements could not be converted to the specified UStruct type.

◆ JsonAttributesToUStruct()

static bool FJsonObjectConverter::JsonAttributesToUStruct ( const TMap< FString, TSharedPtr< FJsonValue > > &  JsonAttributes,
const UStruct *  StructDefinition,
void *  OutStruct,
int64  CheckFlags,
int64  SkipFlags 
)
static

Converts a set of json attributes (possibly from within a JsonObject) to a UStruct, using importText

参数
JsonAttributesJson Object to copy data out of
StructDefinitionUStruct definition that is looked over for properties
OutStructThe UStruct instance to copy in to
CheckFlagsOnly convert properties that match at least one of these flags. If 0 check all properties.
SkipFlagsSkip properties that match any of these flags
返回
False if any properties matched but failed to deserialize

◆ JsonObjectStringToUStruct()

template<typename OutStructType >
static bool FJsonObjectConverter::JsonObjectStringToUStruct ( const FString &  JsonString,
OutStructType *  OutStruct,
int64  CheckFlags,
int64  SkipFlags 
)
inlinestatic

Converts from a json string containing an object to a UStruct

参数
JsonStringString containing JSON formatted data.
OutStructThe UStruct instance to copy in to
CheckFlagsOnly convert properties that match at least one of these flags. If 0 check all properties.
SkipFlagsSkip properties that match any of these flags
返回
False if any properties matched but failed to deserialize

◆ JsonObjectToUStruct() [1/2]

static bool FJsonObjectConverter::JsonObjectToUStruct ( const TSharedRef< FJsonObject > &  JsonObject,
const UStruct *  StructDefinition,
void *  OutStruct,
int64  CheckFlags = 0,
int64  SkipFlags = 0 
)
static

Converts from a Json Object to a UStruct, using importText

参数
JsonObjectJson Object to copy data out of
StructDefinitionUStruct definition that is looked over for properties
StructThe UStruct instance to copy in to
CheckFlagsOnly convert properties that match at least one of these flags. If 0 check all properties.
SkipFlagsSkip properties that match any of these flags
返回
False if any properties matched but failed to deserialize

◆ JsonObjectToUStruct() [2/2]

template<typename OutStructType >
static bool FJsonObjectConverter::JsonObjectToUStruct ( const TSharedRef< FJsonObject > &  JsonObject,
OutStructType *  OutStruct,
int64  CheckFlags = 0,
int64  SkipFlags = 0 
)
inlinestatic

Templated version of JsonObjectToUStruct

参数
JsonObjectJson Object to copy data out of
OutStructThe UStruct instance to copy in to
CheckFlagsOnly convert properties that match at least one of these flags. If 0 check all properties.
SkipFlagsSkip properties that match any of these flags
返回
False if any properties matched but failed to deserialize

◆ JsonValueToUProperty()

static bool FJsonObjectConverter::JsonValueToUProperty ( const TSharedPtr< FJsonValue > &  JsonValue,
FProperty *  Property,
void *  OutValue,
int64  CheckFlags,
int64  SkipFlags 
)
static

Converts a single JsonValue to the corresponding FProperty (this may recurse if the property is a UStruct for instance).

参数
JsonValueThe value to assign to this property
PropertyThe FProperty definition of the property we're setting.
OutValuePointer to the property instance to be modified.
CheckFlagsOnly convert sub-properties that match at least one of these flags. If 0 check all properties.
SkipFlagsSkip sub-properties that match any of these flags
返回
False if the property failed to serialize

◆ StandardizeCase()

static FString FJsonObjectConverter::StandardizeCase ( const FString &  StringIn)
static

FName case insensitivity can make the casing of UPROPERTIES unpredictable.

Attempt to standardize output.

◆ UStructToJsonAttributes()

static bool FJsonObjectConverter::UStructToJsonAttributes ( const UStruct *  StructDefinition,
const void *  Struct,
TMap< FString, TSharedPtr< FJsonValue > > &  OutJsonAttributes,
int64  CheckFlags,
int64  SkipFlags,
const CustomExportCallback *  ExportCb = nullptr 
)
static

Converts from a UStruct to a set of json attributes (possibly from within a JsonObject)

参数
StructDefinitionUStruct definition that is looked over for properties
StructThe UStruct instance to copy out of
JsonAttributesMap of attributes to copy in to
CheckFlagsOnly convert properties that match at least one of these flags. If 0 check all properties.
SkipFlagsSkip properties that match any of these flags
ExportCbOptional callback to override export behavior, if this returns null it will fallback to the default
返回
False if any properties failed to write

◆ UStructToJsonObject() [1/2]

template<typename InStructType >
static TSharedPtr< FJsonObject > FJsonObjectConverter::UStructToJsonObject ( const InStructType &  InStruct,
int64  CheckFlags = 0,
int64  SkipFlags = 0,
const CustomExportCallback *  ExportCb = nullptr 
)
inlinestatic

Templated version of UStructToJsonObject to try and make most of the params.

Also serves as an example use case

参数
InStructThe UStruct instance to read from
ExportCbOptional callback to override export behavior, if this returns null it will fallback to the default
CheckFlagsOnly convert properties that match at least one of these flags. If 0 check all properties.
SkipFlagsSkip properties that match any of these flags
返回
FJsonObject pointer. Invalid if an error occurred.

◆ UStructToJsonObject() [2/2]

static bool FJsonObjectConverter::UStructToJsonObject ( const UStruct *  StructDefinition,
const void *  Struct,
TSharedRef< FJsonObject >  OutJsonObject,
int64  CheckFlags,
int64  SkipFlags,
const CustomExportCallback *  ExportCb = nullptr 
)
static

Converts from a UStruct to a Json Object, using exportText

参数
StructDefinitionUStruct definition that is looked over for properties
StructThe UStruct instance to copy out of
JsonObjectJson Object to be filled in with data from the ustruct
CheckFlagsOnly convert properties that match at least one of these flags. If 0 check all properties.
SkipFlagsSkip properties that match any of these flags
ExportCbOptional callback to override export behavior, if this returns null it will fallback to the default
返回
False if any properties failed to write

◆ UStructToJsonObjectString() [1/2]

template<typename InStructType >
static bool FJsonObjectConverter::UStructToJsonObjectString ( const InStructType &  InStruct,
FString &  OutJsonString,
int64  CheckFlags = 0,
int64  SkipFlags = 0,
int32  Indent = 0,
const CustomExportCallback *  ExportCb = nullptr,
bool  bPrettyPrint = true 
)
inlinestatic

Templated version; Converts from a UStruct to a json string containing an object, using exportText

参数
StructThe UStruct instance to copy out of
JsonObjectJson Object to be filled in with data from the ustruct
CheckFlagsOnly convert properties that match at least one of these flags. If 0 check all properties.
SkipFlagsSkip properties that match any of these flags
IndentHow many tabs to add to the json serializer
ExportCbOptional callback to override export behavior, if this returns null it will fallback to the default
bPrettyPrintOption to use pretty print (e.g., adds line endings) or condensed print
返回
False if any properties failed to write

◆ UStructToJsonObjectString() [2/2]

static bool FJsonObjectConverter::UStructToJsonObjectString ( const UStruct *  StructDefinition,
const void *  Struct,
FString &  OutJsonString,
int64  CheckFlags,
int64  SkipFlags,
int32  Indent = 0,
const CustomExportCallback *  ExportCb = nullptr,
bool  bPrettyPrint = true 
)
static

Converts from a UStruct to a json string containing an object, using exportText

参数
StructDefinitionUStruct definition that is looked over for properties
StructThe UStruct instance to copy out of
JsonObjectJson Object to be filled in with data from the ustruct
CheckFlagsOnly convert properties that match at least one of these flags. If 0 check all properties.
SkipFlagsSkip properties that match any of these flags
IndentHow many tabs to add to the json serializer
ExportCbOptional callback to override export behavior, if this returns null it will fallback to the default
bPrettyPrintOption to use pretty print (e.g., adds line endings) or condensed print
返回
False if any properties failed to write

该类的文档由以下文件生成: