Json in Web.Config AppSettings Json in Web.Config AppSettings json json

Json in Web.Config AppSettings


Not nicely. The web.config is XML and quotes are not allowed in XML without escaping them to ". Doing that on a JSON still will make it "difficult" to read / maintain. Base64 that serhiyb is one solution, but that will not be maintainable by a person either.

I'd store them as appsettings key/value pairs and then generate the json string at runtime.

If you are 100% the string will never change, then escaping or Base64 is an option.


With your limitations I would just encode it to Base64 string and decode it back when you read it from web.config.


If you use " instead of quote characters then you can store JSON in app settings or connection strings without issues in the Web.config. E.g.:

<add key="ThisIsJson" value="[{"Name":"xyz"}]"/>

This doesn't need any special processing either, at least with Json.NET.