Q:

How can we export json as a file through a rest web service?

I am returning an object as json through the existing rest service, however I wish to save the json to the users local disk.

A:

You can write the file in the server. And use the following code to send the file to user.
String path = context.getSession().getServletContext().getRealPath("/") + "path to file";  

InputStream inputStream = prepairFileStream(response, path);
if (inputStream == null) return;

FileCopyUtils.copy(inputStream, response.getOutputStream());

