【发布时间】:2019-06-25 12:07:14
【问题描述】:
我正在尝试使用 Tabulator 创建票证列表,数据通过 AJAX url 从票证系统导入为 JSON,如下所示。
{
"results": [
{
"cc_emails": [
"ram@freshdesk.com",
"diana@freshdesk.com"
],
"fwd_emails": [],
"reply_cc_emails": [
"ram@freshdesk.com",
"diana@freshdesk.com"
],
"ticket_cc_emails": [
"ram@freshdesk.com",
"diana@freshdesk.com"
],
"fr_escalated": false,
"spam": false,
"email_config_id": null,
"group_id": 35000204315,
"priority": 1,
"requester_id": 35020281588,
"responder_id": 35004154466,
"source": 2,
"company_id": null,
"status": 2,
"subject": "Support Needed...",
"association_type": null,
"to_emails": null,
"product_id": null,
"id": 188261,
"type": null,
"due_by": "2019-09-17T15:12:07Z",
"fr_due_by": "2019-07-01T15:12:07Z",
"is_escalated": false,
"description": "<div>Details about the issue...</div>",
"description_text": "Details about the issue...",
"custom_fields": {
"cf_category": null,
"cf_firstname": null,
"cf_surname": null,
"cf_user_trainging": null,
"cf_email_address": null,
"cf_office_365": null,
"cf_start_date": null,
"cf_permission_level": null,
"cf_hardware_type": null,
"cf_additional_information_specsoftware_etc": null,
"cf_vpn_access_required": false,
"cf_securitydistribution_group_membership": null,
"cf_mapped_network_driveslogin_script": null,
"cf_printers": null,
"cf_phone_extension": null,
"cf_ddi": null,
"cf_phone_group_membership": null,
"cf_user_who_requires_the_equipment": null,
"cf_requirment_date": null,
"cf_correctclosureused": null,
"cf_location": "A1"
},
"created_at": "2019-06-24T15:11:47Z",
"updated_at": "2019-06-24T15:59:00Z",
"associated_tickets_count": null,
"tags": []
}
],
"total": 1
}
问题是“custom_fields”是主要 JSON 对象内的 JSON 对象,有没有办法将这些数据展平并将其显示为 Tabulator 中的所有一行?任何帮助表示赞赏?
我在 Tabulator 中的当前结果是它为 custom_fields 列返回 [object Object]。我希望能够看到行中的每个 custom_fields。
【问题讨论】:
-
为什么结果是一个长度 == 1 的数组?它总是长度为 1 的数组吗?
-
我从未使用过
tabulator,但经过一番搜索:Complex JSON Object? #223 和nested data #125 -
看看您如何处理这些数据来设置表格列等会很有趣。
-
只是为了演示它唯一的一个结果,是的,我已经研究过它们,发现它们现在都相当老了,想知道是否有新的解决方案,我在 Repo 上找不到任何东西以获得更新的回复,因此在此处创建问题。
-
如果嵌套的 json 对象的键已经存在于父对象中会怎样?
标签: javascript json tabulator