diff --git a/Libraries/Core/Utils/JsonUtil.cs b/Libraries/Core/Utils/JsonUtil.cs index 85121394..9f1c6be0 100644 --- a/Libraries/Core/Utils/JsonUtil.cs +++ b/Libraries/Core/Utils/JsonUtil.cs @@ -60,21 +60,47 @@ public class JsonUtil }; + /// + /// Convert JSON into an object + /// + /// The type of the object to deserialize to + /// The JSON string to deserialize + /// Deserialized object or null public T? Deserialize(string? json) { return string.IsNullOrEmpty(json) ? default : JsonSerializer.Deserialize(json, jsonSerializerOptionsNoIndent); } + /// + /// Convert JSON into an object + /// + /// The JSON string to deserialize + /// The type of the object to deserialize to + /// public object? Deserialize(string? json, Type type) { return string.IsNullOrEmpty(json) ? null : JsonSerializer.Deserialize(json, type, jsonSerializerOptionsNoIndent); } + /// + /// Convert an object into JSON + /// + /// Type of the object being serialised + /// Object to serialise + /// Should JSON be indented + /// Serialised object as JSON, or null public string? Serialize(T? obj, bool indented = false) { return obj == null ? null : JsonSerializer.Serialize(obj, indented ? jsonSerializerOptionsIndented : jsonSerializerOptionsNoIndent); } + /// + /// Convert an object into JSON + /// + /// Object to serialise + /// Type of object being serialsied + /// Should JSON be indented + /// public string? Serialize(object? obj, Type type, bool indented = false) { return obj == null ? null : JsonSerializer.Serialize(obj, type, indented ? jsonSerializerOptionsIndented : jsonSerializerOptionsNoIndent);