I used JSONGenerator to generate a customized JSON String. I know I can return sObject or String using Salesforce REST. But now I am sure I do not want to return sObject because I want the customized format. But I also do not want to return a String because client app is expecting a strict JSON object. How can I solve this?
If you have a JSON object as a String, you can return it by assigning it to the
Alterntively, you can define an inline Apex class with the format you require. For example: