Adds plugins
This commit is contained in:
31
Plugins/BlueprintJson/BlueprintJson.uplugin
Normal file
31
Plugins/BlueprintJson/BlueprintJson.uplugin
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"FileVersion": 3,
|
||||
"Version": 1,
|
||||
"VersionName": "1.0",
|
||||
"FriendlyName": "JSON Blueprint support",
|
||||
"Description": "JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate.",
|
||||
"Category": "Database",
|
||||
"CreatedBy": "Maksim Shestakov",
|
||||
"CreatedByURL": "",
|
||||
"DocsURL": "",
|
||||
"MarketplaceURL": "com.epicgames.launcher://ue/marketplace/content/f837e4835fbc434a853fe1ead2410b84",
|
||||
"SupportURL": "",
|
||||
"EngineVersion": "4.27.0",
|
||||
"CanContainContent": false,
|
||||
"Installed": true,
|
||||
"Modules": [
|
||||
{
|
||||
"Name": "BlueprintJson",
|
||||
"Type": "Runtime",
|
||||
"LoadingPhase": "PreDefault",
|
||||
"WhitelistPlatforms": [
|
||||
"Win64",
|
||||
"Win32",
|
||||
"Mac",
|
||||
"Linux",
|
||||
"IOS",
|
||||
"Android"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
Plugins/BlueprintJson/Resources/Icon128.png
(Stored with Git LFS)
Normal file
BIN
Plugins/BlueprintJson/Resources/Icon128.png
(Stored with Git LFS)
Normal file
Binary file not shown.
@@ -0,0 +1,24 @@
|
||||
// Copyright 2018 Maksim Shestakov. All Rights Reserved.
|
||||
|
||||
namespace UnrealBuildTool.Rules
|
||||
{
|
||||
public class BlueprintJson : ModuleRules
|
||||
{
|
||||
public BlueprintJson(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
//MinFilesUsingPrecompiledHeaderOverride = 1;
|
||||
//bFasterWithoutUnity = true;
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[] {
|
||||
"Core",
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"Json"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
// Copyright 2018 Maksim Shestakov. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "BlueprintJsonLibrary.generated.h"
|
||||
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EJsonType : uint8
|
||||
{
|
||||
None,
|
||||
Null,
|
||||
String,
|
||||
Number,
|
||||
Boolean,
|
||||
Array,
|
||||
Object
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType, meta = (HasNativeMake = "BlueprintJson.BlueprintJsonLibrary.JsonMake", HasNativeBreak = "BlueprintJson.BlueprintJsonLibrary.Conv_JsonObjectToString"))
|
||||
struct FBlueprintJsonObject
|
||||
{
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
TSharedPtr<class FJsonObject> Object;
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType, meta = (HasNativeMake = "BlueprintJson.BlueprintJsonLibrary.JsonMakeString"))
|
||||
struct FBlueprintJsonValue
|
||||
{
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
TSharedPtr<class FJsonValue> Value;
|
||||
};
|
||||
|
||||
|
||||
UCLASS()
|
||||
class BLUEPRINTJSON_API UBlueprintJsonLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Creates a json object
|
||||
*
|
||||
* @return The json object
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Json", meta = (NativeMakeFunc))
|
||||
static FBlueprintJsonObject JsonMake();
|
||||
|
||||
/**
|
||||
* Sets the value of the field with the specified name.
|
||||
*
|
||||
* @param JsonObject The stored json object
|
||||
* @param FieldName The name of the field to set.
|
||||
* @param Value The json value to set.
|
||||
* @return The stored json object
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Json")
|
||||
static const FBlueprintJsonObject& JsonMakeField(const FBlueprintJsonObject& JsonObject, const FString& FieldName, const FBlueprintJsonValue& Value);
|
||||
|
||||
/**
|
||||
* Sets the value of the field with the specified name.
|
||||
*
|
||||
* @param JsonObject The stored json object
|
||||
* @param FieldName The name of the field to set.
|
||||
* @param Value The json value to set.
|
||||
* @return The stored json object
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "Json")
|
||||
static const FBlueprintJsonObject& JsonSetField(const FBlueprintJsonObject& JsonObject, const FString& FieldName, const FBlueprintJsonValue& JsonValue);
|
||||
|
||||
/**
|
||||
* Checks whether a field with the specified name exists in the json object.
|
||||
*
|
||||
* @param JsonObject The stored json object
|
||||
* @param FieldName The name of the field to check.
|
||||
* @return true if the field exists, false otherwise.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Json")
|
||||
static bool JsonHasField(const FBlueprintJsonObject& JsonObject, const FString& FieldName);
|
||||
|
||||
/**
|
||||
* Checks whether a field with the specified name and type exists in the object.
|
||||
*
|
||||
* @param JsonObject The stored json object
|
||||
* @param FieldName The name of the field to check.
|
||||
* @param Type The type of the field to check.
|
||||
* @return true if the field exists, false otherwise.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Json")
|
||||
static bool JsonHasTypedField(const FBlueprintJsonObject& JsonObject, const FString& FieldName, EJsonType Type);
|
||||
|
||||
/**
|
||||
* Removes the field with the specified name.
|
||||
*
|
||||
* @param JsonObject The stored json object
|
||||
* @param FieldName The name of the field to remove.
|
||||
* @return The stored json object
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "Json")
|
||||
static const FBlueprintJsonObject& JsonRemoveField(const FBlueprintJsonObject& JsonObject, const FString& FieldName);
|
||||
|
||||
/**
|
||||
* Convert json object to json string
|
||||
*
|
||||
* @param JsonObject The stored json object
|
||||
* @param FieldName The name of the field to get.
|
||||
* @return The json value of json object
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, meta = (DisplayName = "ToJsonValue (JsonObject)", CompactNodeTitle = "ToValue", BlueprintAutocast, NativeBreakFunc), Category = "Json|Convert")
|
||||
static FBlueprintJsonValue Conv_JsonObjectToJsonValue(const FBlueprintJsonObject& JsonObject, const FString& FieldName);
|
||||
|
||||
/**
|
||||
* Convert json object to json string
|
||||
*
|
||||
* @param JsonObject The json object to convert
|
||||
* @return The json string
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, meta = (DisplayName = "ToString (JsonObject)", CompactNodeTitle = "ToString", BlueprintAutocast, NativeBreakFunc), Category = "Json|Convert")
|
||||
static FString Conv_JsonObjectToString(const FBlueprintJsonObject& JsonObject);
|
||||
|
||||
/**
|
||||
* Convert json object to pretty print json string
|
||||
*
|
||||
* @param JsonObject The json object to convert
|
||||
* @return The json string
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, meta = (DisplayName = "ToPrettyString (JsonObject)", CompactNodeTitle = "ToPrettyString", NativeBreakFunc), Category = "Json|Convert")
|
||||
static FString Conv_JsonObjectToPrettyString(const FBlueprintJsonObject& JsonObject);
|
||||
|
||||
/**
|
||||
* Convert json string to json object
|
||||
*
|
||||
* @param JsonString The string to convert
|
||||
* @return The json object
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, meta = (DisplayName = "ToJsonObject (String)", CompactNodeTitle = "ToJson"), Category = "Json|Convert")
|
||||
static FBlueprintJsonObject Conv_StringToJsonObject(const FString& JsonString);
|
||||
|
||||
/**
|
||||
* Creates a json value string
|
||||
*
|
||||
* @param Value value to set the string to
|
||||
* @return The blueprint json value
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Json|Make", meta=(NativeMakeFunc))
|
||||
static FBlueprintJsonValue JsonMakeString(const FString& Value);
|
||||
|
||||
/**
|
||||
* Creates a json value int
|
||||
*
|
||||
* @param Value value to set the int to
|
||||
* @return The blueprint json value
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Json|Make", meta = (NativeMakeFunc))
|
||||
static FBlueprintJsonValue JsonMakeInt(int Value);
|
||||
|
||||
/**
|
||||
* Creates a json value float
|
||||
*
|
||||
* @param Value value to set the float to
|
||||
* @return The blueprint json value
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Json|Make", meta = (NativeMakeFunc))
|
||||
static FBlueprintJsonValue JsonMakeFloat(float Value);
|
||||
|
||||
/**
|
||||
* Creates a json value bool
|
||||
|
||||
* @param Value value to set the bool to
|
||||
* @return The blueprint json value
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Json|Make", meta = (NativeMakeFunc))
|
||||
static FBlueprintJsonValue JsonMakeBool(bool Value);
|
||||
|
||||
/**
|
||||
* Creates a json value array
|
||||
*
|
||||
* @param Value value to set the array to
|
||||
* @return The blueprint json value
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Json|Make", meta = (NativeMakeFunc))
|
||||
static FBlueprintJsonValue JsonMakeArray(const TArray<FBlueprintJsonValue>& Value);
|
||||
|
||||
/**
|
||||
* Creates a json value object
|
||||
*
|
||||
* @param Value value to set the json object to
|
||||
* @return The blueprint json value
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Json|Make", meta = (NativeMakeFunc))
|
||||
static FBlueprintJsonValue JsonMakeObject(const FBlueprintJsonObject& Value);
|
||||
|
||||
/**
|
||||
* Creates a json value null
|
||||
*
|
||||
* @return The blueprint json value
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Json|Make", meta = (NativeMakeFunc))
|
||||
static FBlueprintJsonValue JsonMakeNull();
|
||||
|
||||
/** Return the type of json value */
|
||||
UFUNCTION(BlueprintPure, Category = "Json|Value")
|
||||
static EJsonType JsonType(const FBlueprintJsonValue& JsonValue);
|
||||
|
||||
/** Return true if the json value is null, false otherwise */
|
||||
UFUNCTION(BlueprintPure, Category = "Json|Value")
|
||||
static bool JsonIsNull(const FBlueprintJsonValue& JsonValue);
|
||||
|
||||
/** Returns true if the values are equal (A == B) */
|
||||
UFUNCTION(BlueprintPure, meta = (DisplayName = "Equal (JsonValue)", CompactNodeTitle = "=="), Category = "Json|Value")
|
||||
static bool EquaEqual_JsonValue(const FBlueprintJsonValue& A, const FBlueprintJsonValue& B);
|
||||
|
||||
/** Returns true if the values are not equal (A != B) */
|
||||
UFUNCTION(BlueprintPure, meta = (DisplayName = "NotEqual (JsonValue)", CompactNodeTitle = "!="), Category = "Json|Value")
|
||||
static bool NotEqual_JsonValue(const FBlueprintJsonValue& A, const FBlueprintJsonValue& B);
|
||||
|
||||
/** Converts an json value into an string */
|
||||
UFUNCTION(BlueprintPure, meta = (DisplayName = "ToString (JsonValue)", CompactNodeTitle = "->", BlueprintAutocast, NativeBreakFunc), Category = "Json|Value")
|
||||
static FString Conv_JsonValueToString(const FBlueprintJsonValue& JsonValue);
|
||||
|
||||
/** Converts an json value into an int */
|
||||
UFUNCTION(BlueprintPure, meta = (DisplayName = "ToInteger (JsonValue)", CompactNodeTitle = "->", BlueprintAutocast, NativeBreakFunc), Category = "Json|Value")
|
||||
static int Conv_JsonValueToInteger(const FBlueprintJsonValue& JsonValue);
|
||||
|
||||
/** Converts an json value into an float */
|
||||
UFUNCTION(BlueprintPure, meta = (DisplayName = "ToFloat (JsonValue)", CompactNodeTitle = "->", BlueprintAutocast, NativeBreakFunc), Category = "Json|Value")
|
||||
static float Conv_JsonValueToFloat(const FBlueprintJsonValue& JsonValue);
|
||||
|
||||
/** Converts an json value into an bool */
|
||||
UFUNCTION(BlueprintPure, meta = (DisplayName = "ToBool (JsonValue)", CompactNodeTitle = "->", BlueprintAutocast, NativeBreakFunc), Category = "Json|Value")
|
||||
static bool Conv_JsonValueToBool(const FBlueprintJsonValue& JsonValue);
|
||||
|
||||
/** Converts an json value into an array of json value */
|
||||
UFUNCTION(BlueprintPure, meta = (DisplayName = "ToArray (JsonValue)", CompactNodeTitle = "->", BlueprintAutocast, NativeBreakFunc), Category = "Json|Value")
|
||||
static TArray<FBlueprintJsonValue> Conv_JsonValueToArray(const FBlueprintJsonValue& JsonValue);
|
||||
|
||||
/** Converts an json value into an json object */
|
||||
UFUNCTION(BlueprintPure, meta = (DisplayName = "ToJsonObject (JsonValue)", CompactNodeTitle = "->", BlueprintAutocast, NativeBreakFunc), Category = "Json|Value")
|
||||
static FBlueprintJsonObject Conv_JsonValueToObject(const FBlueprintJsonValue& JsonValue);
|
||||
};
|
||||
@@ -0,0 +1,287 @@
|
||||
// Copyright 2018 Maksim Shestakov. All Rights Reserved.
|
||||
|
||||
#include "BlueprintJsonLibrary.h"
|
||||
|
||||
#include "Dom/JsonObject.h"
|
||||
#include "Serialization/JsonWriter.h"
|
||||
#include "Serialization/JsonReader.h"
|
||||
#include "Serialization/JsonSerializer.h"
|
||||
#include "Policies/CondensedJsonPrintPolicy.h"
|
||||
|
||||
typedef TSharedPtr<FJsonObject> FJsonObjectPtr;
|
||||
typedef TSharedPtr<FJsonValue> FJsonValuePtr;
|
||||
|
||||
FBlueprintJsonObject UBlueprintJsonLibrary::JsonMake()
|
||||
{
|
||||
FBlueprintJsonObject Object;
|
||||
Object.Object = MakeShareable(new FJsonObject);
|
||||
return Object;
|
||||
}
|
||||
|
||||
const FBlueprintJsonObject& UBlueprintJsonLibrary::JsonSetField(const FBlueprintJsonObject& JsonObject, const FString& FieldName, const FBlueprintJsonValue& JsonValue)
|
||||
{
|
||||
if (JsonObject.Object.IsValid() && JsonValue.Value.IsValid())
|
||||
{
|
||||
JsonObject.Object->SetField(FieldName, JsonValue.Value);
|
||||
}
|
||||
return JsonObject;
|
||||
}
|
||||
|
||||
bool UBlueprintJsonLibrary::JsonHasField(const FBlueprintJsonObject& JsonObject, const FString& FieldName)
|
||||
{
|
||||
if (JsonObject.Object.IsValid())
|
||||
{
|
||||
return JsonObject.Object->HasField(FieldName);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UBlueprintJsonLibrary::JsonHasTypedField(const FBlueprintJsonObject& JsonObject, const FString& FieldName, EJsonType Type)
|
||||
{
|
||||
if (JsonObject.Object.IsValid())
|
||||
{
|
||||
if (JsonObject.Object->HasField(FieldName))
|
||||
{
|
||||
return JsonObject.Object->GetField<EJson::None>(FieldName)->Type == (EJson)Type;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const FBlueprintJsonObject& UBlueprintJsonLibrary::JsonRemoveField(const FBlueprintJsonObject& JsonObject, const FString& FieldName)
|
||||
{
|
||||
if (JsonObject.Object.IsValid())
|
||||
{
|
||||
JsonObject.Object->RemoveField(FieldName);
|
||||
}
|
||||
return JsonObject;
|
||||
}
|
||||
|
||||
FBlueprintJsonValue UBlueprintJsonLibrary::Conv_JsonObjectToJsonValue(const FBlueprintJsonObject& JsonObject, const FString& FieldName)
|
||||
{
|
||||
FBlueprintJsonValue Value;
|
||||
if (JsonObject.Object.IsValid())
|
||||
{
|
||||
Value.Value = JsonObject.Object->GetField<EJson::None>(FieldName);
|
||||
}
|
||||
return Value;
|
||||
}
|
||||
|
||||
FString UBlueprintJsonLibrary::Conv_JsonObjectToString(const FBlueprintJsonObject& JsonObject)
|
||||
{
|
||||
FString Result;
|
||||
if (JsonObject.Object.IsValid())
|
||||
{
|
||||
TSharedRef<TJsonWriter<TCHAR, TCondensedJsonPrintPolicy<TCHAR>>> JsonWriter = TJsonWriterFactory<TCHAR, TCondensedJsonPrintPolicy<TCHAR>>::Create(&Result, 0);
|
||||
FJsonSerializer::Serialize(JsonObject.Object.ToSharedRef(), JsonWriter);
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
FString UBlueprintJsonLibrary::Conv_JsonObjectToPrettyString(const FBlueprintJsonObject& JsonObject)
|
||||
{
|
||||
FString Result;
|
||||
if (JsonObject.Object.IsValid())
|
||||
{
|
||||
TSharedRef<TJsonWriter<>> JsonWriter = TJsonWriterFactory<>::Create(&Result, 0);
|
||||
FJsonSerializer::Serialize(JsonObject.Object.ToSharedRef(), JsonWriter);
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
FBlueprintJsonObject UBlueprintJsonLibrary::Conv_StringToJsonObject(const FString& JsonString)
|
||||
{
|
||||
FBlueprintJsonObject Object;
|
||||
TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(JsonString);
|
||||
FJsonSerializer::Deserialize(Reader, Object.Object);
|
||||
return Object;
|
||||
}
|
||||
|
||||
const FBlueprintJsonObject& UBlueprintJsonLibrary::JsonMakeField(const FBlueprintJsonObject& JsonObject, const FString& FieldName, const FBlueprintJsonValue& JsonValue)
|
||||
{
|
||||
if (JsonObject.Object.IsValid() && JsonValue.Value.IsValid())
|
||||
{
|
||||
JsonObject.Object->SetField(FieldName, JsonValue.Value);
|
||||
}
|
||||
return JsonObject;
|
||||
}
|
||||
|
||||
FBlueprintJsonValue UBlueprintJsonLibrary::JsonMakeString(const FString& StringValue)
|
||||
{
|
||||
FBlueprintJsonValue Value;
|
||||
Value.Value = MakeShareable(new FJsonValueString(StringValue));
|
||||
return Value;
|
||||
}
|
||||
|
||||
FBlueprintJsonValue UBlueprintJsonLibrary::JsonMakeInt(int IntValue)
|
||||
{
|
||||
FBlueprintJsonValue Value;
|
||||
Value.Value = MakeShareable(new FJsonValueNumber(IntValue));
|
||||
return Value;
|
||||
}
|
||||
|
||||
FBlueprintJsonValue UBlueprintJsonLibrary::JsonMakeFloat(float FloatValue)
|
||||
{
|
||||
FBlueprintJsonValue Value;
|
||||
Value.Value = MakeShareable(new FJsonValueNumber(FloatValue));
|
||||
return Value;
|
||||
}
|
||||
|
||||
FBlueprintJsonValue UBlueprintJsonLibrary::JsonMakeBool(bool BoolValue)
|
||||
{
|
||||
FBlueprintJsonValue Value;
|
||||
Value.Value = MakeShareable(new FJsonValueBoolean(BoolValue));
|
||||
return Value;
|
||||
}
|
||||
|
||||
FBlueprintJsonValue UBlueprintJsonLibrary::JsonMakeArray(const TArray<FBlueprintJsonValue>& ArrayValue)
|
||||
{
|
||||
FBlueprintJsonValue Value;
|
||||
TArray<FJsonValuePtr> Array;
|
||||
for (const FBlueprintJsonValue& V : ArrayValue)
|
||||
{
|
||||
if (V.Value.IsValid())
|
||||
{
|
||||
Array.Add(V.Value);
|
||||
}
|
||||
}
|
||||
Value.Value = MakeShareable(new FJsonValueArray(Array));
|
||||
return Value;
|
||||
}
|
||||
|
||||
FBlueprintJsonValue UBlueprintJsonLibrary::JsonMakeObject(const FBlueprintJsonObject& ObjectValue)
|
||||
{
|
||||
FBlueprintJsonValue Value;
|
||||
Value.Value = MakeShareable(new FJsonValueObject(ObjectValue.Object));
|
||||
return Value;
|
||||
}
|
||||
|
||||
FBlueprintJsonValue UBlueprintJsonLibrary::JsonMakeNull()
|
||||
{
|
||||
FBlueprintJsonValue Value;
|
||||
Value.Value = MakeShareable(new FJsonValueNull());
|
||||
return Value;
|
||||
}
|
||||
|
||||
EJsonType UBlueprintJsonLibrary::JsonType(const FBlueprintJsonValue& JsonValue)
|
||||
{
|
||||
if (JsonValue.Value.IsValid())
|
||||
{
|
||||
return (EJsonType)JsonValue.Value->Type;
|
||||
}
|
||||
return EJsonType::None;
|
||||
}
|
||||
|
||||
bool UBlueprintJsonLibrary::JsonIsNull(const FBlueprintJsonValue& JsonValue)
|
||||
{
|
||||
if (JsonValue.Value.IsValid())
|
||||
{
|
||||
return JsonValue.Value->IsNull();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UBlueprintJsonLibrary::EquaEqual_JsonValue(const FBlueprintJsonValue& A, const FBlueprintJsonValue& B)
|
||||
{
|
||||
if (A.Value.IsValid() != B.Value.IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (A.Value.IsValid() && B.Value.IsValid())
|
||||
{
|
||||
if (!FJsonValue::CompareEqual(*A.Value, *B.Value))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UBlueprintJsonLibrary::NotEqual_JsonValue(const FBlueprintJsonValue& A, const FBlueprintJsonValue& B)
|
||||
{
|
||||
if (A.Value.IsValid() != B.Value.IsValid())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (A.Value.IsValid() && B.Value.IsValid())
|
||||
{
|
||||
if (!FJsonValue::CompareEqual(*A.Value, *B.Value))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
FString UBlueprintJsonLibrary::Conv_JsonValueToString(const FBlueprintJsonValue& JsonValue)
|
||||
{
|
||||
if (JsonValue.Value.IsValid())
|
||||
{
|
||||
return JsonValue.Value->AsString();
|
||||
}
|
||||
FString Empty;
|
||||
return Empty;
|
||||
}
|
||||
|
||||
int UBlueprintJsonLibrary::Conv_JsonValueToInteger(const FBlueprintJsonValue& JsonValue)
|
||||
{
|
||||
if (JsonValue.Value.IsValid())
|
||||
{
|
||||
int Result = 0;
|
||||
JsonValue.Value->TryGetNumber(Result);
|
||||
return Result;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
float UBlueprintJsonLibrary::Conv_JsonValueToFloat(const FBlueprintJsonValue& JsonValue)
|
||||
{
|
||||
if (JsonValue.Value.IsValid())
|
||||
{
|
||||
return JsonValue.Value->AsNumber();
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
bool UBlueprintJsonLibrary::Conv_JsonValueToBool(const FBlueprintJsonValue& JsonValue)
|
||||
{
|
||||
if (JsonValue.Value.IsValid())
|
||||
{
|
||||
return JsonValue.Value->AsBool();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
TArray<FBlueprintJsonValue> UBlueprintJsonLibrary::Conv_JsonValueToArray(const FBlueprintJsonValue& JsonValue)
|
||||
{
|
||||
TArray<FBlueprintJsonValue> Result;
|
||||
|
||||
if (JsonValue.Value.IsValid())
|
||||
{
|
||||
if (JsonValue.Value->Type == EJson::Array)
|
||||
{
|
||||
for (const auto& Val : JsonValue.Value->AsArray())
|
||||
{
|
||||
FBlueprintJsonValue Tmp;
|
||||
Tmp.Value = Val;
|
||||
Result.Add(Tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
FBlueprintJsonObject UBlueprintJsonLibrary::Conv_JsonValueToObject(const FBlueprintJsonValue& JsonValue)
|
||||
{
|
||||
FBlueprintJsonObject Object;
|
||||
if (JsonValue.Value.IsValid())
|
||||
{
|
||||
Object.Object = JsonValue.Value->AsObject();
|
||||
}
|
||||
return Object;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright 2018 Maksim Shestakov. All Rights Reserved.
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Modules/ModuleInterface.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
|
||||
IMPLEMENT_MODULE(IModuleInterface, BlueprintJson)
|
||||
Reference in New Issue
Block a user