{
"MethodParameters": {
"operation": [ "write", "click", "text" ],
"stepDetail": "login",
"welcome": "Hello Bob!"
}
if I want to get the value of "stepDetail" under "MethodParameters".
I’m trying it like this:
public static JObject? jsconfig1 = ReadJson(@"DataFilesjsconfig1.json".ToString());
public static string loginA = .SelectToken("MethodParameters").SelectToken("stepDetail").Value<string>();
but it does not work for me. any help is appreciated.
4
Answers
Why cannot you do something like
{nameOfYourObject}.MethodParameters.stepDetail
?Why don’t try this
Your json is saved in variables you can access to nested field.
You should convert your json to an object with
Newtonsoft.Json
and then work with it as any object.This should be your class: