mirror of https://github.com/Hax-io/libpb
- Cleaned up serialization.d and deserialization.d imports
This commit is contained in:
parent
eeabd9173e
commit
87b564f4e5
|
@ -1,14 +1,12 @@
|
||||||
module libpb.deserialization;
|
module libpb.deserialization;
|
||||||
|
|
||||||
import std.json;
|
import std.json;
|
||||||
|
import std.traits : FieldTypeTuple, FieldNameTuple;
|
||||||
|
|
||||||
public RecordType fromJSON(RecordType)(JSONValue jsonIn)
|
public RecordType fromJSON(RecordType)(JSONValue jsonIn)
|
||||||
{
|
{
|
||||||
RecordType record;
|
RecordType record;
|
||||||
|
|
||||||
import std.traits;
|
|
||||||
import std.meta : AliasSeq;
|
|
||||||
|
|
||||||
// Alias as to only expand later when used in compile-time
|
// Alias as to only expand later when used in compile-time
|
||||||
alias structTypes = FieldTypeTuple!(RecordType);
|
alias structTypes = FieldTypeTuple!(RecordType);
|
||||||
alias structNames = FieldNameTuple!(RecordType);
|
alias structNames = FieldNameTuple!(RecordType);
|
||||||
|
|
|
@ -2,21 +2,13 @@ module libpb.serialization;
|
||||||
|
|
||||||
import std.json;
|
import std.json;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
|
import std.traits : FieldTypeTuple, FieldNameTuple;
|
||||||
debug(dbg)
|
|
||||||
{
|
|
||||||
import std.stdio : writeln;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JSONValue serializeRecord(RecordType)(RecordType record)
|
public JSONValue serializeRecord(RecordType)(RecordType record)
|
||||||
{
|
{
|
||||||
import std.traits;
|
|
||||||
import std.meta : AliasSeq;
|
|
||||||
|
|
||||||
// Final JSON to submit
|
// Final JSON to submit
|
||||||
JSONValue builtJSON;
|
JSONValue builtJSON;
|
||||||
|
|
||||||
|
|
||||||
// Alias as to only expand later when used in compile-time
|
// Alias as to only expand later when used in compile-time
|
||||||
alias structTypes = FieldTypeTuple!(RecordType);
|
alias structTypes = FieldTypeTuple!(RecordType);
|
||||||
alias structNames = FieldNameTuple!(RecordType);
|
alias structNames = FieldNameTuple!(RecordType);
|
||||||
|
@ -84,6 +76,7 @@ unittest
|
||||||
{
|
{
|
||||||
import std.algorithm.searching : canFind;
|
import std.algorithm.searching : canFind;
|
||||||
import std.string : cmp;
|
import std.string : cmp;
|
||||||
|
import std.stdio : writeln;
|
||||||
|
|
||||||
struct Person
|
struct Person
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue