I have a .NET Core 2.x application with multiple types of configuration values. appsettings.json looks like the snippet below and I am trying to read the value of ElasticSearch:MyIndex:mappings as a single string or JSON object.

Is this just a typo? You have a double :: in the key...
– DavidGFeb 22 at 18:09

@DavidG yes, that is a type in my example which does not occur in my code. Fixing it now.
– Babak NaffasFeb 22 at 18:10

Also, you can't call .Value on a complex object, that only works for string values.
– DavidGFeb 22 at 18:11

I was trying anything I could think of to see if it would work or help me figure out some other solution. I have been able to get it working by reading appsettings.json as a JSON file and getting the object I need.
– Babak NaffasFeb 22 at 18:41

I have a work around by parsing appsettings.json directly and reading the property I need. But I still would like to see if there are other options.
– Babak NaffasFeb 22 at 19:51

Then you could read it into a string that can be parsed by just using:

Configuration["ElasticSearch"]

This solution isn't for everyone since it's not fun to look at or update the escaped json, but if you only plan on rarely making changes to this configuration setting then it might not be the worst idea.