object(stdClass)#2 (1) {
["CaseId"]=>
string(27) "SEAD-NLRC-NCR-11-00002-2016"
}
[
{
"Case_ID": "2",
"Case_Status": "Withdrawn",
"Case_Reference_Number": "SEAD-NLRC-NCR-11-00002-2016",
"Case_Date_Filed": "November,24,Thursday,2016 1:30 PM",
"Requesting_Party_Full_Name": "Anak ng diyablo corporation",
"Requesting_Party_Age": "99",
"Requesting_Party_Gender": "",
"Requesting_Party_Address": "sa ilalim ng lupa siyempre",
"Requesting_Party_Full_Contact_Info": "09207819920",
"Requesting_Party_Date_Of_Employment": "30 November, 2016",
"Requesting_Party_Nature_Of_Work": "nag babantay ng mga maiinit na bato",
"Requesting_Party_Salary_Rate": "5000",
"Responding_Party_Full_Name": "angheles junkshop",
"Responding_Party_Nature_Of_Business": "Construction",
"Responding_Type_Of_Enterprise": "MICRO (1-9)",
"Responding_Party_Position": "mercenary naman",
"Responding_Party_HouseNo": "",
"Responding_Party_Street": "",
"Responding_Party_Barangay": "",
"Responding_Party_ZipCode": "",
"Responding_Party_City": "",
"Responding_Party_Contact_Details": "miguelita",
"Responding_Party_Full_Contact_Info": "baklaako@yahoo.com",
"Case_Holder": "DESK-75034-2016",
"Notice_Of_Conference": "None",
"Remarks": "Not Set",
"Remarks_Date": "Not Set",
"Remarks_Time": "Not Set",
"Joint_Conference_Holder": "DESK-00060-2016",
"Lawyer_Holder": "DESK-10101-2017"
}
]
如何以这种格式获取对象内的数据。
我正在使用AngularJS,我希望使用ng-repeat
来调用$http.post
。
答案 0 :(得分:0)
试试这个
<!DOCTYPE html>
<html ng-app="UserValue">
<head>
<script type="text/javascript" src="https://code.angularjs.org/1.5.5/angular.min.js"></script>
<script type="text/javascript">
var app = angular.module('UserValue', []);
app.controller('UserFirstValue', function ($scope) {
$scope.myArray = [{
"Case_ID": "2",
"Case_Status": "Withdrawn",
"Case_Reference_Number": "SEAD-NLRC-NCR-11-00002-2016",
"Case_Date_Filed": "November,24,Thursday,2016 1:30 PM",
"Requesting_Party_Full_Name": "Anak ng diyablo corporation",
"Requesting_Party_Age": "99",
"Requesting_Party_Gender": "",
"Requesting_Party_Address": "sa ilalim ng lupa siyempre",
"Requesting_Party_Full_Contact_Info": "09207819920",
"Requesting_Party_Date_Of_Employment": "30 November, 2016",
"Requesting_Party_Nature_Of_Work": "nag babantay ng mga maiinit na bato",
"Requesting_Party_Salary_Rate": "5000",
"Responding_Party_Full_Name": "angheles junkshop",
"Responding_Party_Nature_Of_Business": "Construction",
"Responding_Type_Of_Enterprise": "MICRO (1-9)",
"Responding_Party_Position": "mercenary naman",
"Responding_Party_HouseNo": "",
"Responding_Party_Street": "",
"Responding_Party_Barangay": "",
"Responding_Party_ZipCode": "",
"Responding_Party_City": "",
"Responding_Party_Contact_Details": "miguelita",
"Responding_Party_Full_Contact_Info": "baklaako@yahoo.com",
"Case_Holder": "DESK-75034-2016",
"Notice_Of_Conference": "None",
"Remarks": "Not Set",
"Remarks_Date": "Not Set",
"Remarks_Time": "Not Set",
"Joint_Conference_Holder": "DESK-00060-2016",
"Lawyer_Holder": "DESK-10101-2017"
}]
});
</script>
</head>
<body ng-controller="UserFirstValue">
<div ng-repeat="data in myArray">
<div>Case_ID: {{data.Case_ID}}</div>
<div>Responding_Party_Position: {{data.Responding_Party_Position}}</div>
<div>Lawyer_Holder: {{data.Lawyer_Holder}}</div>
</div>
</body>
</html>
&#13;
答案 1 :(得分:0)
<强>样本强>
var jsonObj = [
{
"Case_ID": "2",
"Case_Status": "Withdrawn",
"Case_Reference_Number": "SEAD-NLRC-NCR-11-00002-2016",
"Case_Date_Filed": "November,24,Thursday,2016 1:30 PM",
"Requesting_Party_Full_Name": "Anak ng diyablo corporation",
"Requesting_Party_Age": "99",
"Requesting_Party_Gender": "",
"Requesting_Party_Address": "sa ilalim ng lupa siyempre",
"Requesting_Party_Full_Contact_Info": "09207819920",
"Requesting_Party_Date_Of_Employment": "30 November, 2016",
"Requesting_Party_Nature_Of_Work": "nag babantay ng mga maiinit na bato",
"Requesting_Party_Salary_Rate": "5000",
"Responding_Party_Full_Name": "angheles junkshop",
"Responding_Party_Nature_Of_Business": "Construction",
"Responding_Type_Of_Enterprise": "MICRO (1-9)",
"Responding_Party_Position": "mercenary naman",
"Responding_Party_HouseNo": "",
"Responding_Party_Street": "",
"Responding_Party_Barangay": "",
"Responding_Party_ZipCode": "",
"Responding_Party_City": "",
"Responding_Party_Contact_Details": "miguelita",
"Responding_Party_Full_Contact_Info": "baklaako@yahoo.com",
"Case_Holder": "DESK-75034-2016",
"Notice_Of_Conference": "None",
"Remarks": "Not Set",
"Remarks_Date": "Not Set",
"Remarks_Time": "Not Set",
"Joint_Conference_Holder": "DESK-00060-2016",
"Lawyer_Holder": "DESK-10101-2017"
}
];
var res = jsonObj.map(function(item) {
return item.Case_ID;
});
console.log(res);
<强>样本强>
var jsonObj = [
{
"Case_ID": "2",
"Case_Status": "Withdrawn",
"Case_Reference_Number": "SEAD-NLRC-NCR-11-00002-2016",
"Case_Date_Filed": "November,24,Thursday,2016 1:30 PM",
"Requesting_Party_Full_Name": "Anak ng diyablo corporation",
"Requesting_Party_Age": "99",
"Requesting_Party_Gender": "",
"Requesting_Party_Address": "sa ilalim ng lupa siyempre",
"Requesting_Party_Full_Contact_Info": "09207819920",
"Requesting_Party_Date_Of_Employment": "30 November, 2016",
"Requesting_Party_Nature_Of_Work": "nag babantay ng mga maiinit na bato",
"Requesting_Party_Salary_Rate": "5000",
"Responding_Party_Full_Name": "angheles junkshop",
"Responding_Party_Nature_Of_Business": "Construction",
"Responding_Type_Of_Enterprise": "MICRO (1-9)",
"Responding_Party_Position": "mercenary naman",
"Responding_Party_HouseNo": "",
"Responding_Party_Street": "",
"Responding_Party_Barangay": "",
"Responding_Party_ZipCode": "",
"Responding_Party_City": "",
"Responding_Party_Contact_Details": "miguelita",
"Responding_Party_Full_Contact_Info": "baklaako@yahoo.com",
"Case_Holder": "DESK-75034-2016",
"Notice_Of_Conference": "None",
"Remarks": "Not Set",
"Remarks_Date": "Not Set",
"Remarks_Time": "Not Set",
"Joint_Conference_Holder": "DESK-00060-2016",
"Lawyer_Holder": "DESK-10101-2017"
}
];
for(var i in jsonObj) {
console.log(jsonObj[i].Case_ID);
}
ng-repeat
var myApp = angular.module('myApp', []);
myApp.controller('MyCtrl',function($scope) {
$scope.jsonObj = [
{
"Case_ID": "2",
"Case_Status": "Withdrawn",
"Case_Reference_Number": "SEAD-NLRC-NCR-11-00002-2016",
"Case_Date_Filed": "November,24,Thursday,2016 1:30 PM",
"Requesting_Party_Full_Name": "Anak ng diyablo corporation",
"Requesting_Party_Age": "99",
"Requesting_Party_Gender": "",
"Requesting_Party_Address": "sa ilalim ng lupa siyempre",
"Requesting_Party_Full_Contact_Info": "09207819920",
"Requesting_Party_Date_Of_Employment": "30 November, 2016",
"Requesting_Party_Nature_Of_Work": "nag babantay ng mga maiinit na bato",
"Requesting_Party_Salary_Rate": "5000",
"Responding_Party_Full_Name": "angheles junkshop",
"Responding_Party_Nature_Of_Business": "Construction",
"Responding_Type_Of_Enterprise": "MICRO (1-9)",
"Responding_Party_Position": "mercenary naman",
"Responding_Party_HouseNo": "",
"Responding_Party_Street": "",
"Responding_Party_Barangay": "",
"Responding_Party_ZipCode": "",
"Responding_Party_City": "",
"Responding_Party_Contact_Details": "miguelita",
"Responding_Party_Full_Contact_Info": "baklaako@yahoo.com",
"Case_Holder": "DESK-75034-2016",
"Notice_Of_Conference": "None",
"Remarks": "Not Set",
"Remarks_Date": "Not Set",
"Remarks_Time": "Not Set",
"Joint_Conference_Holder": "DESK-00060-2016",
"Lawyer_Holder": "DESK-10101-2017"
}
];
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="MyCtrl">
<div ng-repeat="case in jsonObj">
Case ID : {{case.Case_ID}}
</div>
</div>
注意: AngularJS不允许ng-repeat
指令中的重复项。这意味着如果您尝试执行以下操作,则会出现错误。
<div ng-repeat="names in [alpha,alpha]">
要删除此问题,您必须在track by $index
指令内使用ng-repeat
。
<div ng-repeat="names in [alpha,alpha] track by $index">