我正在使用json-server
将 json 数据作为 REST api 推送。
服务器返回(上图)获取请求,如下所示:
http://localhost:3000/items?itemid=534
返回:
[
{
"itemid": 534,
"type": "textcontent",
"icon": "http://exampple.com/1png",
"title": "John",
"description": "Description",
"url": "http://example.net/project/doSomething"
}
]
回报是JSON array
,但不是JSON object
。
我该怎么办,返回 json 对象
数据文件为:data.json
{
"items": [
{
"itemid": 534,
"type": "textcontent",
"icon": "http://exampple.com/1png",
"title": "John",
"description": "Description",
"url": "http://example.net/project/doSomething"
},
{
"itemid": 234,
"type": "textcontent",
"icon": "http://exampple.com/2png",
"title": "Smith",
"description": "Description2",
"url": "http://example.net/project/doSomething2"
}
]
}