MetaSoul

Loading...
Searching...
No Matches
ESJsonObject.h
Go to the documentation of this file.
1#pragma once
2
3#include "Runtime/Json/Public/Dom/JsonObject.h"
4#include "ESJsonObject.generated.h"
5
6 class UESJsonValue;
7
8UCLASS(BlueprintType, Blueprintable)
9class EMOSHAPESUBSYSTEM_API UESJsonObject : public UObject
10{
11 GENERATED_UCLASS_BODY()
12
13
14 UFUNCTION(BlueprintCallable , meta = (DisplayName = "Construct Json Object", KeyWords = "create make", HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"), Category = "EmoShape|Json")
15 static UESJsonObject* ConstructJsonObject(UObject* WorldContextObject);
16
18 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
19 void Reset();
20
22 TSharedPtr<FJsonObject>& GetRootObject();
23
25 void SetRootObject(const TSharedPtr<FJsonObject>& JsonObject);
26
27
29 // Serialization
30
32 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
33 FString EncodeJson() const;
34
36 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
37 FString EncodeJsonToSingleString() const;
38
40 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
41 bool DecodeJson(const FString& JsonString);
42
43
45 // FJsonObject API
46
48 UFUNCTION(BlueprintPure, Category = "EmoShape|Json")
49 TArray<FString> GetFieldNames();
50
52 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
53 bool HasField(const FString& FieldName) const;
54
56 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
57 void RemoveField(const FString& FieldName);
58
60 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
61 UESJsonValue* GetField(const FString& FieldName) const;
62
64 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
65 void SetField(const FString& FieldName, UESJsonValue* JsonValue);
66
68 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
69 TArray<UESJsonValue*> GetArrayField(const FString& FieldName);
70
72 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
73 void SetArrayField(const FString& FieldName, const TArray<UESJsonValue*>& InArray);
74
76 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
77 void MergeJsonObject(UESJsonObject* InJsonObject, bool Overwrite);
78
79
81 // FJsonObject API Helpers (easy to use with simple Json objects)
82
85 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
86 float GetNumberField(const FString& FieldName) const;
87
90 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
91 void SetNumberField(const FString& FieldName, float Number);
92
94 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
95 FString GetStringField(const FString& FieldName) const;
96
98 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
99 void SetStringField(const FString& FieldName, const FString& StringValue);
100
102 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
103 bool GetBoolField(const FString& FieldName) const;
104
106 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
107 void SetBoolField(const FString& FieldName, bool InValue);
108
110 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
111 UESJsonObject* GetObjectField(const FString& FieldName) const;
112
114 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
115 void SetObjectField(const FString& FieldName, UESJsonObject* JsonObject);
116
118 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
119 void GetBinaryField(const FString& FieldName, TArray<uint8>& OutBinary) const;
120
122 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
123 void SetBinaryField(const FString& FieldName, const TArray<uint8>& Bytes);
124
125
127 // Array fields helpers (uniform arrays)
128
131 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
132 TArray<float> GetNumberArrayField(const FString& FieldName);
133
136 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
137 void SetNumberArrayField(const FString& FieldName, const TArray<float>& NumberArray);
138
140 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
141 TArray<FString> GetStringArrayField(const FString& FieldName);
142
144 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
145 void SetStringArrayField(const FString& FieldName, const TArray<FString>& StringArray);
146
148 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
149 TArray<bool> GetBoolArrayField(const FString& FieldName);
150
152 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
153 void SetBoolArrayField(const FString& FieldName, const TArray<bool>& BoolArray);
154
156 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
157 TArray<UESJsonObject*> GetObjectArrayField(const FString& FieldName);
158
160 UFUNCTION(BlueprintCallable, Category = "EmoShape|Json")
161 void SetObjectArrayField(const FString& FieldName, const TArray<UESJsonObject*>& ObjectArray);
162
163
165 // Data
166
167 private:
169 TSharedPtr<FJsonObject> JsonObj;
170
171};
UESJsonObject
Definition ESJsonObject.h:10
UESJsonValue
Definition ESJsonValue.h:63
UESJsonValue::EncodeJson
FString EncodeJson() const
Definition ESJsonValue.cpp:363