Unrecognized type 'FJsonObject' - type must be a UCLASS, USTRUCT or UENUM

Hello,
I’ve got an error when compiling my custom blueprint nodes and I can’t understand how to solve it.

(.h file)
	UFUNCTION(BlueprintCallable, Category = "Custom Utilities")
		static FJsonObject CreateJsonObject();
(.cpp file)
FJsonObject UMyCustomBPFunctionLibrary::CreateJsonObject()
{
	FJsonObject ReturnJsonObject;
	return ReturnJsonObject;
}

So I made plenty of custom BP Node cuz I prefer scripting in Blueprints and I often need functions that does not exist in bp and I found out that the only ones that work are those that return “normale” types (Like bool, float, etc.)

As soon as I try to make them return me a more complex type defined in libraries (that I ofc include) this is error is popping up and I can’t compile the header (.h) file.

the full error is : Unrecognized type ‘FJsonObject’ - type must be a UCLASS, USTRUCT or UENUM

which brings me to the line : static FJsonObject CreateJsonObject();

The full code is

#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "CoreMisc.h"
#include "PlatformFilemanager.h"
#include "SharedPointer.h"
#include "JsonObject.h"
#include "JsonWriter.h"
#include "JsonSerializer.h"
#include "MyCustomBPFunctionLibrary.generated.h"

UCLASS(BlueprintType, Blueprintable)
 class STEAMPROJECT_API UMyCustomBPFunctionLibrary : public UBlueprintFunctionLibrary
 {
GENERATED_BODY()

UFUNCTION(BlueprintCallable, Category = "Custom Utilities")
	static void SaveMyStringToFile(FString SaveDirectory, FString FileName, FString TextToSave, bool AllowOverwriting);

UFUNCTION(BlueprintPure, Category = "Custom Utilities")
	static FString GetGameDir();

UFUNCTION(BlueprintPure, Category = "Custom Utilities")
	static bool DoesFileExist(FString SaveDirectory, FString FileName);

UFUNCTION(BlueprintCallable, Category = "Custom Utilities")
	static FJsonObject CreateJsonObject();

UFUNCTION(BlueprintCallable, Category = "Custom Utilities")
	static FJsonObject AddStringField(FJsonObject JsonObject, FString Title, FString Description);

UFUNCTION(BlueprintCallable, Category = "Custom Utilities")
	static FJsonObject AddNumberField(FJsonObject JsonObject, FString Title, double Number);

UFUNCTION(BlueprintCallable, Category = "Custom Utilities")
	static FString JsonToString(FJsonObject JsonObject);

};

Thanks for your time :3

UE4’s reflection system requires references, declared by the UFUNCTION/UCLASS/USTRUCT/UENUM macros, to be derived from UObjects. Your functions are returning/taking FJsonObject, which does not inherit from UObject. If you want to use FJsonObjects with the reflection system or blueprints you’re going to have to make a wrapper class that inherits from UObject. Vladimir Alyamkin wrote a pretty good plugin for blueprintable json objects that you can find and refer to here.

1 Like