// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "Serialization/JsonSerializable.h" #include "Misc/Optional.h" class FJsonSerializerReader; /** * Useful if you just want access to the underlying FJsonObject (for cases where the schema is loose or an outer system will do further de/serialization) */ struct FJsonDataBag : public FJsonSerializable { JSON_API virtual void Serialize(FJsonSerializerBase& Serializer, bool bFlatObject) override; JSON_API double GetDouble(const FString& Key) const; JSON_API FString GetString(const FString& Key) const; JSON_API bool GetBool(const FString& Key) const; JSON_API TSharedPtr GetField(const FString& Key) const; template void SetField(const FString& Key, Arg&& Value) { SetFieldJson(Key, MakeShared(Forward(Value))); } JSON_API void SetFieldJson(const FString& Key, const TSharedPtr& Value); public: TSharedPtr JsonObject; /* If set, will use TPrettyJsonPrintPolicy */ TOptional NumPrintIndents; }; template struct TPrettyJsonBag : public FJsonDataBag { TPrettyJsonBag() : FJsonDataBag() { NumPrintIndents.Emplace(PrintIndentCount); } };