是这样的,我有一个obj,是一个json里面嵌套了一个array,数据入下:
[ '炒菜': [ { dishName: '鱼香肉丝',
price: 25,
intro: 'test',
index: 1,
category: '炒菜',
_id: 57666d75c8f2cb97bb07e50b,
dishPic: 'http://localhost:8080/resources/5766671c1002808fbbd09ebd/dishes/57666d75c8f2cb97bb07e50b.jpg',
comment: [],
tags: [Object] },
{ dishName: '宫保板筋',
price: 23,
intro: '',
index: 0,
category: '炒菜',
_id: 57666d75c8f2cb97bb07e50a,
dishPic: 'http://localhost:8080/resources/5766671c1002808fbbd09ebd/dishes/57666d75c8f2cb97bb07e50a.jpg',
comment: [],
tags: [Object] } ],
'火锅': [ { dishName: '海底捞',
price: 250,
intro: 'test',
index: 3,
category: '火锅',
_id: 57666d75c8f2cb97bb07e50d,
dishPic: 'http://localhost:8080/resources/5766671c1002808fbbd09ebd/dishes/57666d75c8f2cb97bb07e50d.jpg',
comment: [],
tags: [Object] },
{ dishName: '黑豆花肉圆子火锅',
price: 80,
intro: 'test',
index: 2,
category: '火锅',
_id: 57666d75c8f2cb97bb07e50c,
dishPic: 'http://localhost:8080/resources/5766671c1002808fbbd09ebd/dishes/57666d75c8f2cb97bb07e50c.jpg',
comment: [],
tags: [Object] } ],
'燃烧': [ { dishName: '凌波',
price: 123,
intro: 'test',
index: 4,
category: '燃烧',
_id: 57666d75c8f2cb97bb07e50e,
dishPic: 'http://localhost:8080/resources/5766671c1002808fbbd09ebd/dishes/57666d75c8f2cb97bb07e50e.jpg',
comment: [],
tags: [Object] } ] ]
我发现res.send(obj)不工作,在 postman里面显示为空
res.json(obj)也不行
但是res.send(obj["火锅"])就可以的,但是我想要一次发送完,请问怎么弄?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
格式错了,最外面得是花括号:
JSON格式错误