I’ve got a REST hello world service up and running with ServiceStack.
It currently returns JSON from a test object that looks like:
{"Name":"Value"}
The object is simply:
public class TestResponse { public string Name { get; set; } }
Does anyone how I can decorate the class to force a root name in the JSON so it appears like so:
{ root:{"Name":"Value"} }
Thanks.
The JSON returned matches the exact shape of the DTO you populate (i.e. the role of a DTO in the first place).
So you should change the DTO to represent the exact shape you want, e.g.
Then you can return it as you would expect:
Or if you prefer, you could also use a Dictionary:
and return it with: