x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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

Product Version: UE Github Master branch
Tags:
more ▼

asked Mar 19 '19 at 02:44 PM in C++ Programming

avatar image

Ciliegino
15 1 2 7

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Mar 22 '19 at 11:03 PM

avatar image

tavolieoffice
1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question