我收到来自HTTP post作为json对象数组的响应。但想显示为字符串。请参阅我的回复..如何将json对象的数组转换为Nodejs中的String?
{ 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(数据))'? –
你可以这样做:'const arrAsStr = arr.map((r)=> JSON.stringify(r));' – Hosar