【发布时间】:2020-06-30 12:36:46
【问题描述】:
似乎 Tabulator 期望来自 JSON 提要(通过 ajax URL 方法访问)的数组以 [] 开头和结尾,但有时只有一个结果 - 所以它只是以 @ 开头和结尾987654323@
这在抛出的错误中很明显:
Data Loading Error - Unable to process data due to invalid data type
Expecting: array
Received: object
有没有办法解决这个问题?
对于单个结果,我的数据如下所示:
{"empId":"123456","firstName":"bini the third","lastName":"rouge","birthDate":"1986-05-04T00:00:00.000+0000","gender":"M","mother":false}
对于多行结果,就像这样:
[
{"empId":"123456","firstName":"bini the third","lastName":"rouge","birthDate":"1986-05-04T00:00:00.000+0000","gender":"M","mother":false},
{"empId":"1111","firstName":"bini the third","lastName":"rouge","birthDate":"1976-05-04T00:00:00.000+0000","gender":"M","mother":false}
]
如您所见,[] 在返回多行时添加,但对于单个结果不存在
【问题讨论】:
-
您是发送 JSON 的 API 开发者吗?如果是这样,只需对其进行编程,以便 API 始终返回一个数组。一个端点上的模棱两可的返回类型通常很糟糕。
-
会试试的,谢谢。但仍然想知道 Tabulator 是否可以在没有
[]的情况下使用这种格式。