Navigation
API > API/Runtime > API/Runtime/JsonUtilities > API/Runtime/JsonUtilities/FJsonSchemaGenerator
Overloads
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static TSharedPtr< FJsonObject > UStructToJsonSchemaObject
(
const FJsonSchemaPropertyFilter& PropertyFilter, |
Templated variant of UStructToJsonSchemaObject() (see above.). | JsonSchema/JsonSchemaGenerator.h | |
static TSharedPtr< FJsonObject > UStructToJsonSchemaObject
(
TNotNull< const UStruct* > Struct, |
Recursively walks Struct's property hierarchy to derive a JSON Schema definition for this type. | JsonSchema/JsonSchemaGenerator.h |
UStructToJsonSchemaObject(const FJsonSchemaPropertyFilter &, FJsonSchemaEditorMetadata *)
Description
Templated variant of UStructToJsonSchemaObject() (see above.).
Works according to struct/class type instead of an taking actual UStruct/UClass reference - i.e. UStructToJsonSchema
| Name | UStructToJsonSchemaObject |
| Type | function |
| Header File | /Engine/Source/Runtime/JsonUtilities/Public/JsonSchema/JsonSchemaGenerator.h |
| Include Path | #include "JsonSchema/JsonSchemaGenerator.h" |
template<typename InStructType>
static TSharedPtr < FJsonObject > UStructToJsonSchemaObject
(
const FJsonSchemaPropertyFilter & PropertyFilter,
FJsonSchemaEditorMetadata * CachedEditorMetadata
)
Schema for the UStruct, as a JSON object.
Parameters
| Name | Remarks |
|---|---|
| PropertyFilter | Determines how to filter collected struct and property data. |
| CachedEditorMetadata | If valid, use this metadata instead of collecting it. Otherwise, it will be automatically collected (if running in Editor context.) This is optional, and used for workflows that have cached metadata from an earlier process. |
UStructToJsonSchemaObject(TNotNull< const UStruct >, const FJsonSchemaPropertyFilter &, const FJsonSchemaEditorMetadata , const void *)
Description
Recursively walks Struct's property hierarchy to derive a JSON Schema definition for this type.
To be called by a developer directly. Attention -
- Struct name is not part of the returned schema.
- If calling in Editor context, metadata will be included. Otherwise, it will not. (i.e. struct's description)
- If Struct is a UFunction, and calling from an Editor context, metadata will only include default values for the function parameters if the function is a Blueprint function.
- If Struct is a UClass, its UFunctions will not be included in the returned schema. TODO - Need a UClass version of this function?
Importantly, the derived JSON Schema describes the JSON which would be produced by FJsonObjectConverter::StructToJsonObject for an instance of the given UStruct. And conversely, any JSON adhering to this JSON Schema, may then be deserialized to an instance of Struct, using FJsonObjectConverter::JsonObjectToUStruct.
e.g: // Details for a person USTRUCT() struct FPerson {
// Full name
FString Name;
// How old they are
int32 Age; }
// A family of people USTRUCT() struct FFamily { // Members of this family
TArray
->
{ "type": "object", "properties": { "members": { "type": "array", "description": "Members of this family", "items": { "type": "object", "properties": { "name": { "type": "string", "description": "Full name" }, "age": { "type": "integer", "description": "How old they are", "minimum": 1 } }, "required": ["name", "age"] } } }, "required": ["members"] }
IMPORTANT - If called while in Editor, schema will include metadata. Otherwise, it will not.
| Name | UStructToJsonSchemaObject |
| Type | function |
| Header File | /Engine/Source/Runtime/JsonUtilities/Public/JsonSchema/JsonSchemaGenerator.h |
| Include Path | #include "JsonSchema/JsonSchemaGenerator.h" |
| Source | /Engine/Source/Runtime/JsonUtilities/Private/JsonSchema/JsonSchemaGenerator.cpp |
static TSharedPtr < FJsonObject > UStructToJsonSchemaObject
(
TNotNull< const UStruct * > Struct,
const FJsonSchemaPropertyFilter & PropertyFilter,
const FJsonSchemaEditorMetadata * CachedEditorMetadata,
const void * InstanceMemory
)
Schema for the UStruct, as a JSON object.
Parameters
| Name | Remarks |
|---|---|
| Struct | The type to build a schema for. Can be either UScriptStruct, UClass or UFunction. |
| PropertyFilter | Determines how to filter collected struct and property data. |
| CachedEditorMetadata | If valid, use this metadata instead of collecting it. Otherwise, it will be automatically collected (if running in Editor context.) This is optional, and used for workflows that have cached metadata from an earlier process. |
| InstanceMemory | When set allows specs to be generated from FInstancedStruct and FInstancedPropertyBag. |