It sounds like you are trying to build a REST or JSON-RPC web service using shiny server. This is not currently possible (with Shiny Server v1.2).
Shiny server renders a text/html template (shinyUI) page and uses WebSocket callbacks to populate the content. The answer from @ScottChamberlain will render the JSON in the HTML body of a web browser. This won't work for a programmatic web request.
I found rApache, Rook and RJSONIO to be a robust and performant solution for JSON web services. You will need to be comfortable with configuring the Apache web server and, depending on your platform, building Apache modules.
rApache is a module that embeds R into the Apache web server allowing you to host Rook, brew and other R frameworks.
Rook defines an interface between R application and a web server. This makes it easy to deliver your JSON payload with the right content-type.
Other options include:
- OpenCPU - A dedicated R HTTP server with explicit support for JSON RPC
- node-rio - node.js server that interfaces RServe
- FastRWeb - CGI or PHP interface to connect a web server to RServe
- RServe - Binary R TCP/IP server
- httpuv - HTTP and WebSocket server library for R
- R's built in rhttpd - not recommended for production use