JSON Data Type Web Resource in Microsoft Dynamics CRM

Here is a simple trick that will allow you to store JSON formatted data in a Web Resource in Microsoft Dynamics CRM.  This provides a much more developer-friendly alternative to the XML data type that CRM offers.  The benefits of using JSON to store and transfer data versus using XML are well known.  It can be done using far less code, and it is much more consistent between different browsers.  Having to support multiple browsers is difficult when working with XML data in javascript because different browsers (or even different versions of the same browser) can behave very differently.  Storing data as a JSON web resource is a much simpler approach, but unfortunately, CRM does not offer a JSON data type for a Web Resource.  Even a plain text type would work for that purpose as well, but that too is unavailable to us.  Luckily, there is a way that we can make this work using a JScript type Web Resource. Where would you actually use this?  In my case, I’ve used this to store configuration details for a managed solution.  The same thing can be accomplished using an XML web resource or a using a custom entity. A JSON Web Resource is significantly easier and less code than working with an entity when loading the data.  The other problem with using an entity record to control solution settings is that records cannot be included in a solution whereas the JSON Web Resource can  be included in a solution. Example Start by creating a new jscript type Web Resource, let’s call it new_config.js.  Then define your object like this:…