I'm trying to set fields of object from JSON with traits library.
How i can to it properly?
import std.stdio;
import std.json;
import std.traits;
import std.meta: Alias;
class Obj{
void fromJSON(this T)(JSONValue j){
foreach(field; FieldNameTuple!T){
On Friday, 16 September 2016 at 08:01:18 UTC, Gary Willoughby
wrote:
On Thursday, 15 September 2016 at 22:05:55 UTC, Ram_B wrote:
test.d(33): Error: variable f cannot be read at compile time
test.d(33): Error: string expected as second argument of
__traits hasMember instead of __error
test.d(46
On Thursday, 15 September 2016 at 15:56:56 UTC, Gary Willoughby
wrote:
On Thursday, 15 September 2016 at 15:07:09 UTC, Ram_B wrote:
How i can get fields of derived classes in runtime? This not
works
What about something like this:
import std.traits;
import std.stdio;
class A {
int a,
On Thursday, 15 September 2016 at 15:56:56 UTC, Gary Willoughby
wrote:
On Thursday, 15 September 2016 at 15:07:09 UTC, Ram_B wrote:
How i can get fields of derived classes in runtime? This not
works
What about something like this:
import std.traits;
import std.stdio;
class A {
int a,
How i can get fields of derived classes in runtime? This not works
import std.traits;
import std.experimental.logger;
class A {
int a,b;
this(){}
void fields(){
log(FieldNameTuple!this);
}
}
class B : A{
int c;
this(){}
}