Re: Serializer class

2017-02-25 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-02-24 19:10, houdoux09 wrote: The problem is that I can not retrieve the variables from the parent class. Cast the value to the type of the base class and run it through the same function. You can have a look at the Orange serialization library [1]. [1] https://github.com/jacob-carl

Re: Serializer class

2017-02-24 Thread houdoux09 via Digitalmars-d-learn
I'm pretty sure you need to use "value.tupleof[i][0]" instead of "mm[0]" as well. it does not work but I found a solution, that's what I do : abstract class BaseClass { uint[] a = [9, 10, 5]; } override class Test : BaseClass { int t = 0; string s = "holla"; } public static JSONVal

Re: Serializer class

2017-02-24 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-02-22 20:13, thedeemon wrote: On Wednesday, 22 February 2017 at 18:34:26 UTC, houdoux09 wrote: void Read(T)(T value) { foreach(i, mm; value.tupleof) { writeln(__traits(identifier, value.tupleof[i]), " = ", mm); if(isArray!(typeof(mm))) { Read(mm[0]); //

Re: Serializer class

2017-02-22 Thread houdoux09 via Digitalmars-d-learn
Yes thank you it works.

Re: Serializer class

2017-02-22 Thread thedeemon via Digitalmars-d-learn
On Wednesday, 22 February 2017 at 18:34:26 UTC, houdoux09 wrote: void Read(T)(T value) { foreach(i, mm; value.tupleof) { writeln(__traits(identifier, value.tupleof[i]), " = ", mm); if(isArray!(typeof(mm))) { Read(mm[0]); //Error } } } You need to us

Serializer class

2017-02-22 Thread houdoux09 via Digitalmars-d-learn
Hello, i am new in D and i have a problem. I would like to retrieve the names of the variables and their value. But i can not retrieve the value of the array. class Test { public int a; public Test[] b; this() { a = 1; b = [new Test(), new Test()]; } } //==