如何在 Nodejs 中将 json 对象数组转换为字符串?
How to convert from array of json object to String in Nodejs?
我从 HTTP post 收到作为 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);
}
NodeJS 有 ES5 JSON
class 其中有 stringify()
方法
function(error, response, data){
if(error) {
console.log(error);
} else {
console.log(JSON.stringify(data));
}
我从 HTTP post 收到作为 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);
}
NodeJS 有 ES5 JSON
class 其中有 stringify()
方法
function(error, response, data){
if(error) {
console.log(error);
} else {
console.log(JSON.stringify(data));
}