mirror of https://github.com/Hax-io/libpb
Attempt at fixing enum type lookups (anything not implicitly in scope of mixin such as built-in types)
This commit is contained in:
parent
2f5710fafb
commit
b10c7d928d
|
@ -3,8 +3,10 @@ module libpb.deserialization;
|
||||||
import std.json;
|
import std.json;
|
||||||
import std.traits : FieldTypeTuple, FieldNameTuple;
|
import std.traits : FieldTypeTuple, FieldNameTuple;
|
||||||
|
|
||||||
public RecordType fromJSON(RecordType)(JSONValue jsonIn)
|
template T(RecordType)
|
||||||
{
|
{
|
||||||
|
public RecordType fromJSON(JSONValue jsonIn)
|
||||||
|
{
|
||||||
RecordType record;
|
RecordType record;
|
||||||
|
|
||||||
// Alias as to only expand later when used in compile-time
|
// Alias as to only expand later when used in compile-time
|
||||||
|
@ -102,6 +104,7 @@ public RecordType fromJSON(RecordType)(JSONValue jsonIn)
|
||||||
}
|
}
|
||||||
|
|
||||||
return record;
|
return record;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
|
@ -128,7 +131,7 @@ unittest
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
|
|
||||||
Person person = fromJSON!(Person)(json);
|
Person person = T!(Person).fromJSON(json);
|
||||||
|
|
||||||
debug(dbg)
|
debug(dbg)
|
||||||
{
|
{
|
||||||
|
|
|
@ -158,7 +158,7 @@ public class PocketBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
recordsOut ~= fromJSON!(RecordType)(returnedItem);
|
recordsOut ~= T!(RecordType).fromJSON(returnedItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
return recordsOut;
|
return recordsOut;
|
||||||
|
@ -268,7 +268,7 @@ public class PocketBase
|
||||||
responseJSON["passwordConfirm"] = "";
|
responseJSON["passwordConfirm"] = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
recordOut = fromJSON!(RecordType)(responseJSON);
|
recordOut = T!(RecordType).fromJSON(responseJSON);
|
||||||
|
|
||||||
return recordOut;
|
return recordOut;
|
||||||
}
|
}
|
||||||
|
@ -349,7 +349,7 @@ public class PocketBase
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
recordOut = fromJSON!(RecordType)(recordResponse);
|
recordOut = T!(RecordType).fromJSON(recordResponse);
|
||||||
|
|
||||||
// Store the token
|
// Store the token
|
||||||
token = responseJSON["token"].str();
|
token = responseJSON["token"].str();
|
||||||
|
@ -448,7 +448,7 @@ public class PocketBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
recordOut = fromJSON!(RecordType)(responseJSON);
|
recordOut = T!(RecordType).fromJSON(responseJSON);
|
||||||
|
|
||||||
return recordOut;
|
return recordOut;
|
||||||
}
|
}
|
||||||
|
@ -553,7 +553,7 @@ public class PocketBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
recordOut = fromJSON!(RecordType)(responseJSON);
|
recordOut = T!(RecordType).fromJSON(responseJSON);
|
||||||
|
|
||||||
return recordOut;
|
return recordOut;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue