From 838ecb2a089d7d11cd04c9efd3f8172dd3fcf546 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Fri, 23 Jun 2023 08:38:15 +0200 Subject: [PATCH] Serializer - Cleaned up - Added documentation Deserializer - Fixed documentation --- source/jstruct/deserializer.d | 19 +++++++++---------- source/jstruct/serializer.d | 9 ++++++++- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/source/jstruct/deserializer.d b/source/jstruct/deserializer.d index 2b24566..62384e2 100644 --- a/source/jstruct/deserializer.d +++ b/source/jstruct/deserializer.d @@ -2,19 +2,18 @@ module jstruct.deserializer; import std.json; import jstruct.exceptions : SerializationError; - import std.traits : FieldTypeTuple, FieldNameTuple; /** - * Deserializes the provided JSON into a struct of type RecordType - * - * Params: - * jsonIn = the JSON to deserialize - * Throws: - * RemoteFieldMissing = if the field names in the provided RecordType - * cannot be found within the prpvided JSONValue `jsonIn`. - * Returns: an instance of RecordType - */ + * Deserializes the provided JSON into a struct of type RecordType + * + * Params: + * jsonIn = the JSON to deserialize + * Throws: + * RemoteFieldMissing = if the field names in the provided RecordType + * cannot be found within the prpvided JSONValue `jsonIn`. + * Returns: an instance of RecordType + */ public RecordType fromJSON(RecordType)(JSONValue jsonIn) { RecordType record; diff --git a/source/jstruct/serializer.d b/source/jstruct/serializer.d index ed492e8..fe8a5de 100644 --- a/source/jstruct/serializer.d +++ b/source/jstruct/serializer.d @@ -3,8 +3,15 @@ module jstruct.serializer; import std.json; import std.conv : to; import std.traits : FieldTypeTuple, FieldNameTuple; - import std.traits : isArray; +import std.traits : isArray; +/** + * Serializes the provided record into JSON + * + * Params: + * record = the record to serialize into + * Returns: A `JSONValue` containing the serialized record + */ public JSONValue serializeRecord(RecordType)(RecordType record) { // Final JSON to submit