呼叫休息後,我得到這個數據在JavaScript中。如何解析JavaScript中的json響應?
{
"error": false,
"orders": [
{
"oid": "764",
"cid": "423",
"name": "Akshay jain",
"address": "infront of gwal magra talab",
"mobile": "11111111",
"email": "[email protected]",
"odate": "2016-03-28 21:50:45",
"status": "NEW ORDER",
"payment": "1",
"ddate": "2016-03-28",
"dtime": "1"
},
{
"oid": "763",
"cid": "438",
"name": "Vishwakarma Ji",
"address": "Narayan Pura Road",
"mobile": "0000000000",
"email": null,
"odate": "2016-03-28 20:02:06",
"status": "Confirmed (Ready for Delivery)",
"payment": "1",
"ddate": "2016-03-28",
"dtime": null
}
]
}
這是我如何存儲在控制器中。
$scope.result = Order.query(); // where Order is a service in angularjs
如果我想打印$ scope.result.error它給對象對象不是實際的錯誤值。
如何解析JavaScript錯誤和訂單,並將其保存在一個變量?
'VAR數據= JSON.parse( 'server.response' );' –