如何从 json.stringify: ionic 中读取特定值

How to read a particular value from the json.stringify: ionic

从 post 我得到了一个资源

.subscribe( res => {
    let result = JSON.stringify(res);
    alert(result)
})

& 作为 alert(result) 的回应,我得到

{"access_token": "hjhdshJHUHYI67HUjhhk98BJ_BJHBBHbnbhbhbjh_jmnhghmghgfffgxcgfcf98hujh",
 "expires_in":"518399"}

这里我想读取 access_token 值并将其保存在一个变量中,我该怎么做?

只需使用通常的语法访问对象的 属性。

.subscribe( res => {
    let the_variable = res['access_token']; //or `result.access_token`
})

您不必进行字符串化,只需将其作为 res.access_token

访问即可
.subscribe((res:any) => {
  let result = res.access_token;
  alert(result)
})
.subscribe( res => {
    alert(res.access_token)
})
.subscribe( res => {
     alert(res.access_token)
 })

如果您无法通过以下解决方案解决您的问题..

不需要对结果进行字符串化。 请尝试以下..

.subscribe( res => {
    alert(res['access_token']);
})