This can be done with mockJax: https://github.com/appendto/jquery-mockjax/ Here you can intercept the request and sent it to a test json file. It also allow you to return other data types, so you can test the "non valid json" issue.
$.mockjax({
url: '/restful/api',
proxy: '/mocks/data.json'
});