json-server
JSONデータをREST APIとしてプッシュするために使用しています。
サーバーは次のような get 要求に対して (上記) を返します。
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"
}
]
}