how to minify service function result with TJsonObject result type?

Here's my dilemma: if the result of a service function is string, XData creates JSON with {"result":"actual result"}, so I cannot easily return my JSON string and it would need to be double-parsed by the caller. But if I use TJsonObject as the result type, it returns it horribly beautified. Is there an easy way to make it return a minified single-line / no extra spaces string?

You can define the global JSON formatting for XData servers by setting JsonDefaultIndent variable:

uses XData.Consts;

...
JsonDefaultIndent := 0;

Other than this, your XData service can return a TStream object, in this way you have full control over the content of the response body.