Is it possible to pass in an argument to a dynamic object, so it returns the object required at runtime?
var file = File.ReadAllText("file.json");
dynamic json = JsonConvert.DeserializeObject(file);
var value = GetValue("EnvironmentConfiguration.Environment");
private static string GetValue(string jsonKey) {
// pass jsonKey somehow here? Something like this...
return json.(jsonKey);
}
Is this even possible?
EDIT:
Json file:
{
"EnvironmentConfiguration":
{
"Environment": "local"
}
}
Assuming we want to get the value "local" from "EnvironmentConfiguration.Environment".