mirror of https://github.com/Hax-io/jstruct
Serializer
- Cleaned up - Added documentation Deserializer - Fixed documentation
This commit is contained in:
parent
40118feffb
commit
838ecb2a08
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue