leo c leo c - 1 year ago 72
JSON Question

can't access nested JSON

When I try to display the object using console log, I am getting undefined. The line of code is:

var inform = data.Payload;
// If access allowed, set redirect location

The data is a JSON object with the following values:

"StatusCode": 200,
"Payload": "{\"sub\":\"1234567-1234-1234-1234-123456778\",\"token_use\":\"access\",\"scope\":\"aws.cognito.signin.user.admin\",\"iss\":\"https://cognito-idp.us-east-1.amazonaws.com/us-east-1_99999999999\",\"exp\":1468310126,\"client_id\":\"xxxxxxxxxxxxx\",\"username\":\"usernam\"}"

I wanted to check the value of token_use.

Answer Source
var inform = JSON.parse(data.Payload);

You need to parson payload since its stringify

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download