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,7 +3,9 @@ module libpb.deserialization;
|
|||
import std.json;
|
||||
import std.traits : FieldTypeTuple, FieldNameTuple;
|
||||
|
||||
public RecordType fromJSON(RecordType)(JSONValue jsonIn)
|
||||
template T(RecordType)
|
||||
{
|
||||
public RecordType fromJSON(JSONValue jsonIn)
|
||||
{
|
||||
RecordType record;
|
||||
|
||||
|
@ -103,6 +105,7 @@ public RecordType fromJSON(RecordType)(JSONValue jsonIn)
|
|||
|
||||
return record;
|
||||
}
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
|
@ -128,7 +131,7 @@ unittest
|
|||
}
|
||||
`);
|
||||
|
||||
Person person = fromJSON!(Person)(json);
|
||||
Person person = T!(Person).fromJSON(json);
|
||||
|
||||
debug(dbg)
|
||||
{
|
||||
|
|
|
@ -158,7 +158,7 @@ public class PocketBase
|
|||
}
|
||||
}
|
||||
|
||||
recordsOut ~= fromJSON!(RecordType)(returnedItem);
|
||||
recordsOut ~= T!(RecordType).fromJSON(returnedItem);
|
||||
}
|
||||
|
||||
return recordsOut;
|
||||
|
@ -268,7 +268,7 @@ public class PocketBase
|
|||
responseJSON["passwordConfirm"] = "";
|
||||
}
|
||||
|
||||
recordOut = fromJSON!(RecordType)(responseJSON);
|
||||
recordOut = T!(RecordType).fromJSON(responseJSON);
|
||||
|
||||
return recordOut;
|
||||
}
|
||||
|
@ -349,7 +349,7 @@ public class PocketBase
|
|||
}
|
||||
|
||||
|
||||
recordOut = fromJSON!(RecordType)(recordResponse);
|
||||
recordOut = T!(RecordType).fromJSON(recordResponse);
|
||||
|
||||
// Store the token
|
||||
token = responseJSON["token"].str();
|
||||
|
@ -448,7 +448,7 @@ public class PocketBase
|
|||
}
|
||||
}
|
||||
|
||||
recordOut = fromJSON!(RecordType)(responseJSON);
|
||||
recordOut = T!(RecordType).fromJSON(responseJSON);
|
||||
|
||||
return recordOut;
|
||||
}
|
||||
|
@ -553,7 +553,7 @@ public class PocketBase
|
|||
}
|
||||
}
|
||||
|
||||
recordOut = fromJSON!(RecordType)(responseJSON);
|
||||
recordOut = T!(RecordType).fromJSON(responseJSON);
|
||||
|
||||
return recordOut;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue