Use the JSON built-in services to create the content.
Branch on the Accept header to determine the type of content to create and the Content-Type header to return.
The somewhat tricky part is if the callers will provide different types in the request. IS will “help” you by parsing the content, depending upon your handlers and config settings, putting different variables in the pipeline for your top-level service to use. In this case, you’ll need to first determine what type of input you are passed and take appropriate action.