tengo este objeto
{ 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier': '918312asdasc812', 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name': 'Login1', 'http://schemas.microsoft.com/ws/2008/06/identity/claims/role': 'User' }¿Cómo se lee el valor de la clave 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier'?
Solución:
obj['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier']Gracias @Andy
Solución:
obj['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier']para acceder a pares de clave y valor en un objeto, puede usar Object.entries(yourObjName) .
foo = { 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier': '918312asdasc812', 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name': 'Login1', 'http://schemas.microsoft.com/ws/2008/06/identity/claims/role': 'User' } for (const [key, value] of Object.entries(foo)) { console.log(`${key}: ${value}`); }lea más información sobre Object.entries()
Puede poner los valores del objeto en una matriz y acceder a la matriz:
const object1 = { 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier': '918312asdasc812', 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name': 'Login1', 'http://schemas.microsoft.com/ws/2008/06/identity/claims/role': 'User' }; const arr = (Object.values(object1)); console.log(arr[0]);