On Thursday, 24 March 2016 at 17:03:25 UTC, Andre wrote:
I hoped there is some operator overloading for implicit
conversion of my
class to JSONValue.
I solved the issue with an toJSON method and a generic
functionality which
checks for this method.
Kind regards
André
Vibe.d has some serial
On Thursday, 24 March 2016 at 16:03:13 UTC, Edwin van Leeuwen
wrote:
On Thursday, 24 March 2016 at 11:39:13 UTC, arturg wrote:
isnt alias this supposed to do this implicitly?
convert this
auto jsValue = JSONValue(new MyClass());
into this
auto jsValue = JSONValue((new MyClass())._data);
Good
On Thursday, 24 March 2016 at 11:39:13 UTC, arturg wrote:
isnt alias this supposed to do this implicitly?
convert this
auto jsValue = JSONValue(new MyClass());
into this
auto jsValue = JSONValue((new MyClass())._data);
Good point, I did not catch that. That indeed should work and
seems to be
On Thursday, 24 March 2016 at 08:24:46 UTC, Edwin van Leeuwen
wrote:
JSONValue only works with the build in types, not with user
defined types. Either you define a specific function for the
class that returns a JSONValue. Easiest way to do that would be
to build an associative array with string
On Thursday, 24 March 2016 at 08:24:46 UTC, Edwin van Leeuwen
wrote:
Alternatively there are multiple serialization libraries that
will allow you to turn any user defined type from and to
JSONValues.
https://code.dlang.org/packages/painlessjson
https://code.dlang.org/packages/jsonizer
Cheers,
On Thursday, 24 March 2016 at 08:15:12 UTC, Andre wrote:
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;
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