On Tue, 21 Jan 2014 09:47:34 +0100, Sönke Ludwig wrote:
Am 21.01.2014 09:23, schrieb Kai-Heng Feng:
I am not sure how to implement this via registerRestInterface.
I've tried:
Json rest_api(string param0, string param1) { Json j; j.id = "1"; return j; }
which causes an exception with message:
...Got JSON of type undefined, expected object....
So, is there a formal way to return a JSON through POST?
Thanks.
This approach is supposed to be correct, the error is caused by the
Json
value not being initialized toType.object
. Please try to
replaceJson j;
withJson j = Json.emptyObject;
and see if it works.
Thanks! It works flawlessly.
I came from C++ world,
I assumed that since Json is a struct, it should be default-initialized.
But in D world, struct is initialized by a factory function, am I right?