Can't access object property, even though it shows up in a console log

后端 未结 30 1769
日久生厌
日久生厌 2020-11-22 06:26

Below, you can see the output from these two logs. The first clearly shows the full object with the property I\'m trying to access, but on the very next line of code, I can\

30条回答
  •  孤独总比滥情好
    2020-11-22 07:01

    My data was just json data string . (This variable was stored as json string in the session).

    console.log(json_string_object)
    

    -> returns just the representation of this string and there is no way to make difference whether is string or object.

    So to make it work I just needed to convert it back to real object:

    object = JSON.parse(json_string_object);
    

提交回复
热议问题