【发布时间】:2017-03-29 20:57:02
【问题描述】:
我收到来自 HTTP 帖子的响应作为 json 对象数组。但想显示为字符串。请看我的回复。。
{ total: 14,
results:
[ { name: [Object],
comments: [],
attributes: [Object],
type: [Object],
context: [Object],
status: 'Accepted',
score: 1.7646775,
modified: 1426085315767,
parents: [] },
{ name: [Object],
comments: [],
attributes: [Object],
type: [Object],
context: [Object],
status: 'Accepted',
score: 1.3945999,
modified: 1425386916807,
parents: [] },
下面的代码显示响应。
function(error, response, data){
if(error) {
console.log(error);
} else {
console.log(data);
}
【问题讨论】:
-
你能用
console.log(JSON.stringify(data))吗? -
你可以用地图做到这一点:
const arrAsStr = arr.map( (r) => JSON.stringify(r) );
标签: javascript json node.js node-modules