I have this JSON string value as defined below. I want to get he value for "code" only. I tried the solution in the internet but I am only getting a null value. Any idea on this?
JObject json = JObject.Parse(JSON string here);
var jsonData = json.SelectToken("serviceMessage.code"); <-- THIS RETURNS NULL
The json:
{
"highestSeverity":"Error",
"serviceMessage":[
{
"code":"3004",
"severity":"Error",
"reason":"Reason here."
}
]
}
serviceMessageis an array . Therefore it doesn't have a "code" property, but the first item within the array does...