Skip to main content
Version: 2.x

UOdinJsonObject

Declaration
UCLASS(BlueprintType, Blueprintable, ClassGroup = Odin)
class ODIN_API UOdinJsonObject : public UObject
  • Header: #include "OdinJsonObject.h"
  • Module: Odin
  • Inherits from: UObject
  • Blueprint: Blueprint type, Blueprintable · Blueprint reference

Overview​

Functions​

NameDescription
ConstructJsonObjectCreates an empty JSON object.
ConstructJsonObjectFromStringCreates a JSON object by parsing a JSON string.
ConstructJsonObjectFromBytesCreates a JSON object by parsing UTF-8 encoded JSON bytes, e.g.
ResetRemoves all fields of the object.
GetRootObject
SetRootObject
EncodeJsonSerializes the object to a JSON string.
EncodeJsonBytesSerializes the object to UTF-8 encoded JSON bytes, e.g.
DecodeJsonDecodes a JSON string.
GetFieldNamesReturns the names of all fields of the object.
HasFieldReturns true if the object has a field with the given name.
RemoveFieldRemoves the field with the given name.
GetFieldReturns the value of a field as a JSON value.
SetFieldSets a field to a JSON value.
SetFieldNullSets a field to null.
GetArrayFieldReturns the elements of an array field as JSON values.
SetArrayFieldSets a field to an array of JSON values.
MergeJsonObjectCopies all fields of another JSON object into this one.
GetNumberFieldReturns the value of a number field.
SetNumberFieldSets a field to a number.
GetStringFieldReturns the value of a string field.
SetStringFieldSets a field to a string.
GetBoolFieldReturns the value of a boolean field.
SetBoolFieldSets a field to a boolean.
GetObjectFieldReturns the value of an object field as a JSON object.
SetObjectFieldSets a field to a JSON object.
GetNumberArrayFieldReturns the elements of an array field as numbers.
SetNumberArrayFieldSets a field to an array of numbers.
GetStringArrayFieldReturns the elements of an array field as strings.
SetStringArrayFieldSets a field to an array of strings.
GetBoolArrayFieldReturns the elements of an array field as booleans.
SetBoolArrayFieldSets a field to an array of booleans.
GetObjectArrayFieldReturns the elements of an array field as JSON objects.
SetObjectArrayFieldSets a field to an array of JSON objects.

Functions​

ConstructJsonObject​

Static · Blueprint: Construct Json Object

Creates an empty JSON object.

UFUNCTION(BlueprintCallable, Category = "Odin|Json Utilities")
static UOdinJsonObject* ConstructJsonObject(UObject* WorldContextObject);
ParameterTypeDescription
WorldContextObjectUObject*

Returns UOdinJsonObject*

ConstructJsonObjectFromString​

Static · Blueprint: Construct Json Object From String

Creates a JSON object by parsing a JSON string.

UFUNCTION(BlueprintCallable, Category = "Odin|Json Utilities")
static UOdinJsonObject* ConstructJsonObjectFromString(UObject* WorldContextObject, const FString& Data);
ParameterTypeDescription
WorldContextObjectUObject*
Dataconst FString&The JSON string.

Returns UOdinJsonObject*

ConstructJsonObjectFromBytes​

Static · Blueprint: Construct Json Object From Bytes

Creates a JSON object by parsing UTF-8 encoded JSON bytes, e.g. the user data of a peer.

UFUNCTION(BlueprintCallable, Category = "Odin|Json Utilities")
static UOdinJsonObject* ConstructJsonObjectFromBytes(UObject* WorldContextObject, const TArray<uint8>& Data);
ParameterTypeDescription
WorldContextObjectUObject*
Dataconst TArray<uint8>&The JSON bytes.

Returns UOdinJsonObject*

Reset​

Blueprint: Reset

Removes all fields of the object.

UFUNCTION(BlueprintCallable, Category = "Odin|Json Utilities")
void Reset();

GetRootObject​

TSharedPtr<FJsonObject>& GetRootObject();

Returns TSharedPtr<FJsonObject>&

SetRootObject​

void SetRootObject(const TSharedPtr<FJsonObject>& JsonObject);
ParameterTypeDescription
JsonObjectconst TSharedPtr<FJsonObject>&

EncodeJson​

Const · Blueprint: Encode Json

Serializes the object to a JSON string.

UFUNCTION(BlueprintPure, Category = "Odin|Json Utilities")
FString EncodeJson() const;

Returns FString

EncodeJsonBytes​

Const · Blueprint: Encode Json Bytes

Serializes the object to UTF-8 encoded JSON bytes, e.g. to use as peer user data.

UFUNCTION(BlueprintPure, Category = "Odin|Json Utilities")
TArray<uint8> EncodeJsonBytes() const;

Returns TArray<uint8>

DecodeJson​

Blueprint: Decode Json

Decodes a JSON string. If the provided string is successfully parsed into a valid JSON object, it updates the internal structure of this object. If parsing fails, the internal state is reset to clear any existing data.

UFUNCTION(BlueprintCallable, Category = "Odin|Json Utilities")
bool DecodeJson(const FString& JsonString);
ParameterTypeDescription
JsonStringconst FString&The JSON formatted string to be decoded.

Returns bool – true if the JSON string was successfully parsed and decoded, false if the decoding failed.

GetFieldNames​

Const · Blueprint: Get Field Names

Returns the names of all fields of the object.

UFUNCTION(BlueprintPure, Category = "Odin|Json Utilities")
TArray<FString> GetFieldNames() const;

Returns TArray<FString>

HasField​

Const · Blueprint: Has Field

Returns true if the object has a field with the given name.

UFUNCTION(BlueprintPure, Category = "Odin|Json Utilities")
bool HasField(const FString& FieldName) const;
ParameterTypeDescription
FieldNameconst FString&

Returns bool

RemoveField​

Blueprint: Remove Field

Removes the field with the given name.

UFUNCTION(BlueprintCallable, Category = "Odin|Json Utilities")
void RemoveField(const FString& FieldName);
ParameterTypeDescription
FieldNameconst FString&

GetField​

Const · Blueprint: Get Field

Returns the value of a field as a JSON value.

UFUNCTION(BlueprintPure, Category = "Odin|Json Utilities")
UOdinJsonValue* GetField(const FString& FieldName) const;
ParameterTypeDescription
FieldNameconst FString&

Returns UOdinJsonValue*

SetField​

Blueprint: Set Field

Sets a field to a JSON value.

UFUNCTION(BlueprintCallable, Category = "Odin|Json Utilities")
void SetField(const FString& FieldName, UOdinJsonValue* JsonValue);
ParameterTypeDescription
FieldNameconst FString&
JsonValueUOdinJsonValue*

SetFieldNull​

Blueprint: Set Field Null

Sets a field to null.

UFUNCTION(BlueprintCallable, Category = "Odin|Json Utilities")
void SetFieldNull(const FString& FieldName);
ParameterTypeDescription
FieldNameconst FString&

GetArrayField​

Const · Blueprint: Get Array Field

Returns the elements of an array field as JSON values.

UFUNCTION(BlueprintPure, Category = "Odin|Json Utilities")
TArray<UOdinJsonValue*> GetArrayField(const FString& FieldName) const;
ParameterTypeDescription
FieldNameconst FString&

Returns TArray<UOdinJsonValue*>

SetArrayField​

Blueprint: Set Array Field

Sets a field to an array of JSON values.

UFUNCTION(BlueprintCallable, Category = "Odin|Json Utilities")
void SetArrayField(const FString& FieldName, const TArray<UOdinJsonValue* >& InArray);
ParameterTypeDescription
FieldNameconst FString&
InArrayconst TArray<UOdinJsonValue*>&

MergeJsonObject​

Blueprint: Merge Json Object

Copies all fields of another JSON object into this one.

UFUNCTION(BlueprintCallable, Category = "Odin|Json Utilities")
void MergeJsonObject(UOdinJsonObject* InJsonObject, bool Overwrite);
ParameterTypeDescription
InJsonObjectUOdinJsonObject*The object to copy the fields from.
OverwriteboolWhether existing fields are replaced.

GetNumberField​

Const · Blueprint: Get Number Field

Returns the value of a number field.

UFUNCTION(BlueprintPure, Category = "Odin|Json Utilities")
float GetNumberField(const FString& FieldName) const;
ParameterTypeDescription
FieldNameconst FString&

Returns float

SetNumberField​

Blueprint: Set Number Field

Sets a field to a number.

UFUNCTION(BlueprintCallable, Category = "Odin|Json Utilities")
void SetNumberField(const FString& FieldName, float Number);
ParameterTypeDescription
FieldNameconst FString&
Numberfloat

GetStringField​

Const · Blueprint: Get String Field

Returns the value of a string field.

UFUNCTION(BlueprintPure, Category = "Odin|Json Utilities")
FString GetStringField(const FString& FieldName) const;
ParameterTypeDescription
FieldNameconst FString&

Returns FString

SetStringField​

Blueprint: Set String Field

Sets a field to a string.

UFUNCTION(BlueprintCallable, Category = "Odin|Json Utilities")
void SetStringField(const FString& FieldName, const FString& StringValue);
ParameterTypeDescription
FieldNameconst FString&
StringValueconst FString&

GetBoolField​

Const · Blueprint: Get Bool Field

Returns the value of a boolean field.

UFUNCTION(BlueprintPure, Category = "Odin|Json Utilities")
bool GetBoolField(const FString& FieldName) const;
ParameterTypeDescription
FieldNameconst FString&

Returns bool

SetBoolField​

Blueprint: Set Bool Field

Sets a field to a boolean.

UFUNCTION(BlueprintCallable, Category = "Odin|Json Utilities")
void SetBoolField(const FString& FieldName, bool InValue);
ParameterTypeDescription
FieldNameconst FString&
InValuebool

GetObjectField​

Const · Blueprint: Get Object Field

Returns the value of an object field as a JSON object.

UFUNCTION(BlueprintCallable, Category = "Odin|Json Utilities")
UOdinJsonObject* GetObjectField(const FString& FieldName) const;
ParameterTypeDescription
FieldNameconst FString&

Returns UOdinJsonObject*

SetObjectField​

Blueprint: Set Object Field

Sets a field to a JSON object.

UFUNCTION(BlueprintCallable, Category = "Odin|Json Utilities")
void SetObjectField(const FString& FieldName, UOdinJsonObject* JsonObject);
ParameterTypeDescription
FieldNameconst FString&
JsonObjectUOdinJsonObject*

GetNumberArrayField​

Blueprint: Get Number Array Field

Returns the elements of an array field as numbers.

UFUNCTION(BlueprintPure, Category = "Odin|Json Utilities")
TArray<float> GetNumberArrayField(const FString& FieldName);
ParameterTypeDescription
FieldNameconst FString&

Returns TArray<float>

SetNumberArrayField​

Blueprint: Set Number Array Field

Sets a field to an array of numbers.

UFUNCTION(BlueprintCallable, Category = "Odin|Json Utilities")
void SetNumberArrayField(const FString& FieldName, const TArray<float>& NumberArray);
ParameterTypeDescription
FieldNameconst FString&
NumberArrayconst TArray<float>&

GetStringArrayField​

Blueprint: Get String Array Field

Returns the elements of an array field as strings.

UFUNCTION(BlueprintPure, Category = "Odin|Json Utilities")
TArray<FString> GetStringArrayField(const FString& FieldName);
ParameterTypeDescription
FieldNameconst FString&

Returns TArray<FString>

SetStringArrayField​

Blueprint: Set String Array Field

Sets a field to an array of strings.

UFUNCTION(BlueprintCallable, Category = "Odin|Json Utilities")
void SetStringArrayField(const FString& FieldName, const TArray<FString>& StringArray);
ParameterTypeDescription
FieldNameconst FString&
StringArrayconst TArray<FString>&

GetBoolArrayField​

Blueprint: Get Bool Array Field

Returns the elements of an array field as booleans.

UFUNCTION(BlueprintPure, Category = "Odin|Json Utilities")
TArray<bool> GetBoolArrayField(const FString& FieldName);
ParameterTypeDescription
FieldNameconst FString&

Returns TArray<bool>

SetBoolArrayField​

Blueprint: Set Bool Array Field

Sets a field to an array of booleans.

UFUNCTION(BlueprintCallable, Category = "Odin|Json Utilities")
void SetBoolArrayField(const FString& FieldName, const TArray<bool>& BoolArray);
ParameterTypeDescription
FieldNameconst FString&
BoolArrayconst TArray<bool>&

GetObjectArrayField​

Const · Blueprint: Get Object Array Field

Returns the elements of an array field as JSON objects.

UFUNCTION(BlueprintPure, Category = "Odin|Json Utilities")
TArray<UOdinJsonObject*> GetObjectArrayField(const FString& FieldName) const;
ParameterTypeDescription
FieldNameconst FString&

Returns TArray<UOdinJsonObject*>

SetObjectArrayField​

Blueprint: Set Object Array Field

Sets a field to an array of JSON objects.

UFUNCTION(BlueprintCallable, Category = "Odin|Json Utilities")
void SetObjectArrayField(const FString& FieldName, const TArray<UOdinJsonObject* >& ObjectArray);
ParameterTypeDescription
FieldNameconst FString&
ObjectArrayconst TArray<UOdinJsonObject*>&