Using JSON Light in SharePoint Server 2013
One of the irritations of using the SharePoint REST API was that to get JSON returned instead of XML you had to specify "odata=verbose" in your accept header. This means you have to set up your AJAX request in a slightly more complicated way, for example you can't use the handy jQuery getJSON method because it doesn't give you an opportunity to set the headers. Instead you have to use something like:
$.ajax({
url: encodeURI("http://litvs13/_api/web/title"),
headers: {
accept: "application/json;odata=verbose"
}
}).done(function (data) {
$("#output").text("Site title: " + data.d.Title);
}).fail(function (msg) {
$("#output").text("Request Failed: " + msg);
});
Solution
The solution is now posted to Technet. You need to run the script in the article which adds some assembly references to the web.config (specifically Microsoft.Data.Edm, Microsoft.Data.Odata, Microsoft.Data.Services, Microsoft.Data.Services.Client and System.Spatial). These are required to support OData 3 and JSON Light and are not added by default. I would recommend the GUI version of the WcfDataServices.exe installer (remembering to check the GAC option) as the command line returns immediately and you have no feel for progress of the installer, which can take a couple of minutes. You might conclude that it hasn't worked when it is in fact still running.
One problem I found is that for some reason after installing WCF Data Services and running the JSON.ps1 script, the REST endpoint was completely broken (error log showed it couldn't find the DLLs for WCF 5.0). I had to run the WcfDataServices.exe installer again to 'Repair' WCF Data Services. I also had to do an IISRESET, presumably to reset the DLL bindings. After this everything worked. Not sure if this is something peculiar to my environment - I am using Windows Server 2012 and I have Visual Studio 2013 installed which might be a factor (see http://blah.winsmarts.com/2014-1-VS2013_and_SharePoint2013.aspx).
So a sequence that worked for me was to run WcfDataServices.exe (5.6 version), Options - install to GAC. After it finishes, run WcfDataServices.exe again clicking on 'Repair'. Then run JSON.ps1 to update web.config.
After that you can get rid of the "odata=verbose" qualifiers on your accept headers or pick from a number of supported OData formats. More importantly you can streamline your network traffic by using the more compact JSON Light format, but don't forget that the format is slightly different (no more "d" wrapping element for example). In my opinion it is worth the effort because the JSON Light payloads are significantly smaller and more efficient.