I have a very dynamic json object. Example below
//sometime like this
{
"message": {
"aaa": [
"This is aaa"
],
"bbb": [
"This is bbb"
],
"ccc": [
"This is ccc",
"Maybe ddd"
]
}
}
//sometime like this
{
"message": {
"fff": [
"This is fff"
],
}
}
//and sometime like this
{
"message": "This is a message"
}
I wish to extract any String inside array and turn it into an array of String. Expected result below
//expected result 1
[
"This is aaa",
"This is bbb",
"This is ccc",
"Maybe ddd"
]
//expected result 2
[
"This is fff"
]
//expected result 3
[
"This is a message"
]
[...?mapVar['message']?.keys];and can append to a universal list. then I will change that map variable to its keys. likemapVar = mapVar.keysthen I will again go through this variable in while loop till I get empty or single element like you stated in test case 3. but there is a problem that I cannot type cast a single variable from map to list of strings so that I cannot check the condition in Loop