5#include "CoreMinimal.h"
6#include "Kismet/BlueprintFunctionLibrary.h"
7#include "JsonObjectConverter.h"
8#include "JsonFuncLib.generated.h"
16 static bool StringToJson(
const FString& JsonString, TSharedPtr<FJsonObject>& JsonObject);
17 static bool JsonToString(
const TSharedPtr<FJsonObject>& JsonObject, FString& JsonString);
19 template <
typename OutStructType>
20 static bool ParseJSONToStruct(
const FString& Data, OutStructType* OutStruct)
22 TSharedPtr<FJsonObject> JsonObject;
23 if (!UJsonFuncLib::StringToJson(Data, JsonObject))
return false;
25 FJsonObjectConverter::JsonObjectToUStruct(JsonObject.ToSharedRef(), OutStruct, 0, 0);
28 static FString RemoveOptionalValuesThatNotSet(
const FString& JsonString);
29 static void RemoveEmptyArrays(
const TSharedPtr<FJsonObject>& JsonObject);
32 static FString MakeFunctionsString(
const TSharedPtr<FJsonObject>& Json);
33 static FString CleanUpFunctionsObject(
const FString& Input);
36 static bool OpenAIResponseContainsError(
const TSharedPtr<FJsonObject>& JsonObject);
39 static const FString START_FUNCTION_OBJECT_MARKER;
40 static const FString END_FUNCTION_OBJECT_MARKER;
42 static void RemoveOptionalValuesInJsonObject(
const TSharedPtr<FJsonObject>& JsonObject);
43 static void ProcessJsonArrayRemovingEmptyArrays(TArray<TSharedPtr<FJsonValue>>& JsonArray);
Definition: JsonFuncLib.h:12