【问题标题】:how to get the values from Jsonstringify using angular4?如何使用角度 4 从 Json Stringify 获取值?
【发布时间】:2018-12-03 18:16:32
【问题描述】:

我从回复中尝试过这样的:

{success: true, result: {picture: "picture-1529913236852.jpg"}}

我只需要从jsonstringify 获取图片,这是我的代码:

this.http.post('myurl', uploadData)
.subscribe(res =>{
    console.log("meee"+JSON.stringify(res));
    this.imageResp = JSON.stringify(res.picture) // here i cant take my picture values
});

请帮帮我。

【问题讨论】:

  • 你能分享一下使用 typeof(res) 的 typeof 响应是什么吗?

标签: json angular stringify


【解决方案1】:

您不需要 JSON.stringify,因为它已经是一个对象,

随便用

this.imageResp = res.result.picture;

【讨论】:

  • 你需要 res.result.picture
  • 我不知道你说的分开图片的格式
  • @SelvaMeena 在从 res.result.picture 获取之前,您可以检查返回的 json 是否真的有 picture
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-20
  • 1970-01-01
  • 1970-01-01
  • 2019-03-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多