Strange behaviour of to!string and JSON

2015-12-03 Thread Suliman via Digitalmars-d
void login(HTTPServerRequest req, HTTPServerResponse res) { Json request = req.json; writeln(to!string(request["username"])); writeln(request["username"].to!string); } Why first code print output with quotes, and second not? "asd" asd

Re: Strange behaviour of to!string and JSON

2015-12-03 Thread Sönke Ludwig via Digitalmars-d
Am 03.12.2015 um 09:46 schrieb Suliman: void login(HTTPServerRequest req, HTTPServerResponse res) { Json request = req.json; writeln(to!string(request["username"])); writeln(request["username"].to!string); } Why first code print output with quotes, and second not? "asd" asd The first one

Re: Strange behaviour of to!string and JSON

2015-12-03 Thread wobbles via Digitalmars-d
On Thursday, 3 December 2015 at 08:46:44 UTC, Suliman wrote: void login(HTTPServerRequest req, HTTPServerResponse res) { Json request = req.json; writeln(to!string(request["username"])); writeln(request["username"].to!string); } Why first code print output with quotes, and second not? "asd" a

Re: Strange behaviour of to!string and JSON

2015-12-03 Thread Vladimir Panteleev via Digitalmars-d
On Thursday, 3 December 2015 at 10:17:17 UTC, Sönke Ludwig wrote: But isn't there a way to customize std.conv.to!T for T other than string? I believe you do that by implementing opCast?

Re: Strange behaviour of to!string and JSON

2015-12-07 Thread Sönke Ludwig via Digitalmars-d
Am 03.12.2015 um 12:18 schrieb Vladimir Panteleev: On Thursday, 3 December 2015 at 10:17:17 UTC, Sönke Ludwig wrote: But isn't there a way to customize std.conv.to!T for T other than string? I believe you do that by implementing opCast? Right, forgot about that. Unfortunately that would stre