我有一个javascript,我通过它调用一个rest api并获得一个JSON结果,我需要一个java类中的这个结果。
下面是脚本
<script type="text/javascript">
function getCurrentTime()
{
var time;
AJS.$.ajax({
url: "/rest/vertygosla/1.0/compute/issue/TST-30",
type: 'get',
dataType: 'json',
async: false,
success: function(data) {
time = data.sla;
}
});
return time[0].remainingTime;
}
alert(""+getCurrentTime())
</script>
json 由服务器提供 {"issueKey":"TST-30","issueId":11600,"created":"2013-01-31T11:38:38.765+0530","sla":[{"agreementName": "确认时间","remainingTime":5860985,"endDate":"2013-01-31T12:00:57.796+0530","startDate":"2013-01-31T11:38:38.781+0530","consumedTime" :1339015,"name":"Ack time","id":11000,"delayed":false,"close":true,"frozen":false}]}
有人可以在 JAVA 中给我一个类似的例子吗?
谢谢