Hi,

I have a class which has already an alias this to a string array,
so I can use it in a foreach loop.

class MyClass
{
        string[] _data;
        alias _data this;
        // ...
}

void main()
{
        import std.json;
        auto jsValue = JSONValue(new MyClass());
}

For some generic code I need an implicit conversion of MyClass so I can use it for a JSONValue. For the coding above I receive a compiler error:
static assert  "unable to convert type "MyClass" to json"

Is there anything I can do?

Kind regards
André

Reply via email to