Home > Mobile >  How read value from uri key json
How read value from uri key json

Time:12-17

i have this object

{
  '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'
}

How read value for key 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier'?

Solution:

obj['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier']

CodePudding user response:

You can put the values of the object in an array and access the array:

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]);

CodePudding user response:

to access key, value pairs in an object you can use 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}`);
}

read more information on Object.entries()

CodePudding user response:

Thanks @Andy

Solution:

obj['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier']
  • Related