I am struggling with error messages that have a nested structure like this:
var data =
{"message":"An issue has occurred.",
"exceptionMessage":"An error occurred while updating the entries. Refer to the inner exception for more details.",
"exceptionType":"System.Data.Entity.Infrastructure.DbUpdateException",
"innerException":{
"message":"An issue has occurred.",
"exceptionMessage":"An error occurred while updating the entries. Refer to the inner exception for more details.",
"exceptionType":"System.Data.Entity.Core.UpdateException",
"innerException":{
"message":"An issue has occurred.",
"exceptionMessage":"Message 1"}
}
}
or
var data =
{"message":"An issue has occurred.",
"exceptionMessage":"An error occurred while updating the entries. Refer to the inner exception for more details.",
"exceptionType":"System.Data.Entity.Infrastructure.DbUpdateException",
"innerException":{
"message":"An issue has occurred.",
"exceptionMessage":"Message 2",
"exceptionType":"System.Data.Entity.Core.UpdateException",
}
}
Can someone assist me in finding a way to extract the message from the innermost "innerException" in these two JSON strings? It's challenging due to the varying number of inner exceptions. I need a solution to retrieve the message from the most inside "innerException".