I have the following query
By means of a ajax
I get this json
{"messageList":{"USER_DATA":{"nombre":"pablo","apellido":"santamarina"},"SESION_DATA":{"isUserLogin":"true"}}}
What I want to do now is to go through the objects within messageList
and access the key of each one but ideally without a for
in
For now I have this code but I'm still not accessing the value I need
ServicesController.prototype.newMessageInvoice = function(dataSource)
{
var msgList = dataSource.messageList;
for (var message in msgList) {
var message = msgList[message];
}
}
I clarify, I need to access the values of the keys, so that the return is for example " USER_DATA
" or " SESION_DATA
", since I have to evaluate what type that message is.
I understand that the way would be to do something like this:
Object.keys(message)[0]
but I'm not stopping correctly inside the object