Javascript 在AngularJS中解析JSON
我需要解析angularJS中的jsonJavascript 在AngularJS中解析JSON,javascript,html,angularjs,Javascript,Html,Angularjs,我需要解析angularJS中的json { "status": true, "previous_status": "", "pass": true, "name": "N/A", "payment_date": "March 5, 2018 - 1:54 pm", "address": "N/A", "city": "N/A", "state": "N/A", "country": "N/A", "checksu
{
"status": true,
"previous_status": "",
"pass": true,
"name": "N/A",
"payment_date": "March 5, 2018 - 1:54 pm",
"address": "N/A",
"city": "N/A",
"state": "N/A",
"country": "N/A",
"checksum": "1009-1",
"custom_fields": [
[
"Ticket Type",
"Friday ticket - 2018"
],
[
"Buyer Name",
"Jhon Doe"
],
[
"Buyer E-mail",
"demo@email.com"
]
]
}
我使ng重复,但在HTML中显示
[“车票类型”、“星期五车票”]
[“买方名称”、“Jhon Doe”]
[“买方电子邮件”demo@email.com“]
我需要像这样的
车票类型:周五车票
代码段:
function fetch() {
$http({
method: 'GET',
url: url,
timeout: 6000
}).then(
function(result) {
$scope.tickets = result.data;
}
);
}
在将该数组呈现为HTML之前,需要对其进行映射 这个替代方案不会改变原始数据
var-app=angular.module('myApp',[]);
应用程序控制器('myCtrl',函数($scope){
$scope.custom_字段=[
[“车票类型”、“2018年星期五车票”],
[“买方名称”、“Jhon Doe”],
[“买方电子邮件”demo@email.com"]
];
$scope.mapped=$scope.custom_fields.map(函数(c){
返回{
标题:c[0],
正文:c[1]
};
});
});代码>
{{entry.title}:{{entry.text}
请共享代码的工作片段。执行类似于{{custom\u字段[0]}}:{{{custom\u字段[1]}}
的操作。让我觉得它应该是一个对象而不是一个array@HassanImam准备好了:谢谢!忘记删除原始电子邮件,您可以从答复中更改它。也许用我刚才放的那个。@JuanDavid完成了!