我正在使用项目请求来使用他/她的学生ID检索学生的出勤信息。
<Request method="GET" item="true">
<Query>
select subject, in_time, out_time
from tbl_attendance where student_id = $id
</Query>
</Request>
目前我正在以下面的格式获取此请求的json。
https://api.metamug.com/tinkertech/v1.0/attendance/1000
[
{
"out_time": "2017-03-18 12:00:01.0",
"in_time": "2017-03-18 12:00:01.0",
"subject": "Maths"
},
{
"out_time": "2017-03-19 13:00:01.0",
"in_time": "2017-03-18 12:00:01.0",
"subject": "Bio"
}
]
我正在尝试按照这个答案生成事件json Jquery Full Calendar json event source syntax
答案 0 :(得分:2)
更改资源xml中的SQL,如下所示:
<Query>
SELECT subject AS title, DATE_FORMAT(in_time,'%Y-%m-%dT%T') AS start,
DATE_FORMAT(out_time,'%Y-%m-%dT%T') AS end
FROM tbl_attendance WHERE student_id=$id
</Query>
请注意&#39; AS&#39; keyword用于在响应中命名JSON密钥。这应该将您的上述JSON响应转换为以下内容:
[
{
"end": "2017-03-18 12:00:01",
"start": "2017-03-18 12:00:01",
"title": "Maths"
},
{
"end": "2017-03-19 13:00:01",
"start": "2017-03-18 12:00:01",
"title": "Bio"
}
]