5#include "CoreMinimal.h"
6#include "Kismet/BlueprintFunctionLibrary.h"
7#include "VaRestJsonValue.h"
8#include "Dom/JsonValue.h"
11#include "VaRestSubsystem.h"
12#include "ApexLibrary.generated.h"
24 UFUNCTION(BlueprintCallable, Category = "
Apex|API")
25 static
FXAPIExtension CreateExtensionData(const TMap<FString, UVaRestJsonValue*>& Data);
27 UFUNCTION(BlueprintCallable, Category = "
Apex|API")
28 static UVaRestJsonValue* JsonValueFromString(FString String);
32 static TArray<TSharedPtr<FJsonValue>> ConvertToJsonValueStringArray(const TArray<FString>& Array)
34 TArray<TSharedPtr<FJsonValue>> ConvertedArray;
35 for (
const FString& Item : Array)
37 TSharedPtr<FJsonValueString> ItemPtr(
new FJsonValueString(Item));
38 ConvertedArray.Add(ItemPtr);
41 return ConvertedArray;
44 static TArray<TSharedPtr<FJsonValue>> ConvertToJsonValueObjectArray(
const TArray<FJsonable>& Array)
46 TArray<TSharedPtr<FJsonValue>> ConvertedArray;
49 TSharedPtr<FJsonValueObject> ItemPtr(
new FJsonValueObject(Item.ToJsonObject()));
50 ConvertedArray.Add(ItemPtr);
53 return ConvertedArray;
56 static bool TryFillFromStringField(
const TSharedPtr<FJsonObject>& JObject,
const FString Field, FString& ValueToFill)
58 if (JObject->HasField(Field))
60 ValueToFill = JObject->GetStringField(Field);
67 static bool TryFillFromBoolField(
const TSharedPtr<FJsonObject>& JObject,
const FString Field,
bool& ValueToFill)
69 if (JObject->HasField(Field))
71 ValueToFill = JObject->GetBoolField(Field);
78 static bool TryFillFromNumberField(
const TSharedPtr<FJsonObject>& JObject,
const FString Field,
float& ValueToFill)
80 if (JObject->HasField(Field))
82 ValueToFill = JObject->GetNumberField(Field);
89 static bool TryFillFromIntegerField(
const TSharedPtr<FJsonObject>& JObject,
const FString Field,
int& ValueToFill)
91 if (JObject->HasField(Field))
93 ValueToFill = JObject->GetIntegerField(Field);
100 static bool TryFillFromObjectField(
const TSharedPtr<FJsonObject>& JObject,
const FString Field,
FJsonable& ValueToFill)
102 if (JObject->HasField(Field))
111 static bool TryFillFromObjectArrayField(
const TSharedPtr<FJsonObject>& JObject,
const FString Field, TArray<FJsonable>& ArrayToFill)
113 if (JObject->HasField(Field))
115 TArray<TSharedPtr<FJsonValue>> Array = JObject->GetArrayField(Field);
117 for (TSharedPtr<FJsonValue> Value : Array)
120 ArrayToFill.Add(Jsonable);
128 static bool TryFillFromStringArrayField(
const TSharedPtr<FJsonObject>& JObject,
const FString Field, TArray<FString>& ArrayToFill)
130 if (JObject->HasField(Field))
132 TArray<TSharedPtr<FJsonValue>> Array = JObject->GetArrayField(Field);
133 for (TSharedPtr<FJsonValue> Value : Array)
135 ArrayToFill.Add(Value->AsString());
143 static bool TryFillFromNumberArrayField(
const TSharedPtr<FJsonObject>& JObject,
const FString Field, TArray<float>& ArrayToFill)
145 if (JObject->HasField(Field))
147 TArray<TSharedPtr<FJsonValue>> Array = JObject->GetArrayField(Field);
148 for (TSharedPtr<FJsonValue> Value : Array)
150 ArrayToFill.Add(Value->AsNumber());
158 static bool TryFillFromIntegerArrayField(
const TSharedPtr<FJsonObject>& JObject,
const FString Field, TArray<int>& ArrayToFill)
160 if (JObject->HasField(Field))
162 TArray<TSharedPtr<FJsonValue>> Array = JObject->GetArrayField(Field);
163 for (TSharedPtr<FJsonValue> Value : Array)
165 ArrayToFill.Add(Value->AsNumber());
173 static bool TryFillFromBoolArrayField(
const TSharedPtr<FJsonObject>& JObject,
const FString Field, TArray<bool>& ArrayToFill)
175 if (JObject->HasField(Field))
177 TArray<TSharedPtr<FJsonValue>> Array = JObject->GetArrayField(Field);
178 for (TSharedPtr<FJsonValue> Value : Array)
180 ArrayToFill.Add(Value->AsBool());
188 static UVaRestSubsystem* GetRestSubsystem()
190 static UVaRestSubsystem* VaRestSubsystem = GEngine->GetEngineSubsystem<UVaRestSubsystem>();
191 return VaRestSubsystem;
194 static FString GetApexSDKVersion();
static bool TryFillFromObjectArrayField(const TSharedPtr< FJsonObject > &JObject, const FString Field, TArray< FJsonable > &ArrayToFill)
static TArray< TSharedPtr< FJsonValue > > ConvertToJsonValueObjectArray(const TArray< FJsonable > &Array)
static bool TryFillFromIntegerArrayField(const TSharedPtr< FJsonObject > &JObject, const FString Field, TArray< int > &ArrayToFill)
static bool TryFillFromNumberArrayField(const TSharedPtr< FJsonObject > &JObject, const FString Field, TArray< float > &ArrayToFill)
static bool TryFillFromIntegerField(const TSharedPtr< FJsonObject > &JObject, const FString Field, int &ValueToFill)
static bool TryFillFromObjectField(const TSharedPtr< FJsonObject > &JObject, const FString Field, FJsonable &ValueToFill)
static TArray< TSharedPtr< FJsonValue > > ConvertToJsonValueStringArray(const TArray< FString > &Array)
static bool TryFillFromBoolField(const TSharedPtr< FJsonObject > &JObject, const FString Field, bool &ValueToFill)
static bool TryFillFromNumberField(const TSharedPtr< FJsonObject > &JObject, const FString Field, float &ValueToFill)
static bool TryFillFromStringField(const TSharedPtr< FJsonObject > &JObject, const FString Field, FString &ValueToFill)
static bool TryFillFromBoolArrayField(const TSharedPtr< FJsonObject > &JObject, const FString Field, TArray< bool > &ArrayToFill)
static UVaRestSubsystem * GetRestSubsystem()
static bool TryFillFromStringArrayField(const TSharedPtr< FJsonObject > &JObject, const FString Field, TArray< FString > &ArrayToFill)
virtual void FromJsonObject(const TSharedPtr< FJsonObject > &JObject)