【发布时间】:2018-09-15 02:42:10
【问题描述】:
我从 URL 获取数据。并且数据看起来像下面的代码。如何访问图像源和内容? (请注意,当我 console.log data.description 时,它控制台未定义)。
data:{
title: "title of the data"
description:"<div class="feed-description"><p style="text-align: center;"><img alt="" src="http://....jpg" style="width: 600px; height: 350px;" /></p><p><government's financial crisis?</p><p>Working out us realling good for your body(<em>depass</em>).</p><p>Finance Ministry insider disclosed that the annual <em>depass</em> at the State House cost.</p></div>"
}
【问题讨论】:
-
您确定这是实际响应吗?如果是这样,您应该修复损坏的 API,以便它返回正确的可解析 JSON。
-
是的,这就是我得到的回复。它已获取 rss 提要 URL(一个网站)。
-
假设
data实际上是一个真实的对象,你可以试试console.log(JSON.stringify(data))。 JS 对象的控制台表示不能很好地转换为复制/粘贴文本 -
即使在使用 'JSON.stringify(data)' 我也只能控制 'data' 而不是 'data.discription'
标签: javascript json xml object