I only want to do this for a couple requests, so I do not want to use the global:
JsConfig.IncludeNullValues = true;
Is there a way to do this only for a specific request? Possibly an attribute on the request?
// pseudo code
public class MyService : Service {
[JsConfig.IncludeNullValues]
public async Task<ResponseDto> Get(RequestDto request) {
// do something
return new ResponseDto();
}
}
So found this…
If this is how to do it… I don’t like how it would be hidden in AppHost. It’s not as clear/explicit as an attribute would be that a request would include NULLs.
But if that is the only way then that is how it shall be.
Put all your initialization/start up logic with the rest of your configuration where it belongs, in your AppHost. Doesn’t make sense to scatter it across static constructors which you can’t control when exactly it’s run.
The Customize JSON Responses in your Service docs show how you can customize the JSON per Service by returning a HttpResult with a ResultScope or by returning the serialized JSON string.
Alternatively you can customize the JSON on-the-fly on the querystring, e.g: