I have a API response, which is like the below code
const res = {
"a" : {},
"a" : {}
}
This is not possible. In JSON, there is no error if you use the same name for multiple keys, but the last key with the same name will be used. I suggest using an array for the values for a key.
E.g.:
const res = {
"a" : {},
"a" : {}
}
would be
const res = {
"a" : [{}, {}]
}
Then you could iterate on the list.
Error: Duplicate key 'a'will be shown