// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved. #pragma once #include "Engine/Core/ISerializable.h" #include "Engine/Core/Types/Span.h" #include "Engine/Core/Collections/Array.h" /// /// Objects serialization tool (json format). /// API_CLASS(Static, Namespace="FlaxEngine.Json") class FLAXENGINE_API JsonSerializer { DECLARE_SCRIPTING_TYPE_MINIMAL(JsonSerializer); /// /// Performs object Json serialization to the raw bytes. /// /// The object to serialize (can be null). /// The output data. API_FUNCTION() static Array SaveToBytes(ISerializable* obj); /// /// Performs object Json deserialization from the raw bytes. /// /// The object to deserialize (can be null). /// The source data to read from. /// The engine build number of the saved data. Used to resolve old object formats when loading deprecated data. FORCE_INLINE static void LoadFromBytes(ISerializable* obj, const Array& data, int32 engineBuild) { LoadFromBytes(obj, Span(data.Get(), data.Count()), engineBuild); } /// /// Performs object Json deserialization from the raw bytes. /// /// The object to deserialize (can be null). /// The source data to read from. /// The engine build number of the saved data. Used to resolve old object formats when loading deprecated data. API_FUNCTION() static void LoadFromBytes(ISerializable* obj, const Span& data, int32 engineBuild); };