Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Json in Web.Config AppSettings

I am trying to put some mapping config represented in json:

[{"Name":"xyz","Ids":["456f782d468","c65b4703"]},{"Name":"abc","Ids":["a95fg567","456sdf564"]}]

Is it possible to store a json in appsettings?
I know I can create a custom section in web.config.
But this app may be deployed to Azure Web Apps where appsettings is the only way I see this config can go.

like image 258
Srinivas Avatar asked Sep 03 '25 06:09

Srinivas


1 Answers

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.

like image 113
SledgeHammer Avatar answered Sep 04 '25 20:09

SledgeHammer