如何解决期望'EOF'的JSON验证

时间:2020-08-06 12:00:04

标签: json

我正在一个医院数据库系统上工作,我在其中使用JSON来显示患者数据时遇到了JSON错误,并且已经通过http://jsonlint.com/进行了验证。 这是我在通过http://jsonlint.com/;验证时得到的错误

document.querySelector(".loginbtn")

这是生成该错误的JSON脚本。该脚本已经输入了一些演示数据;

Error: Parse error on line 9:
... Delete<\/a>"]   ]} <div style = "borde
---------------------^
Expecting 'EOF', '}', ',', ']', got 'undefined'

1 个答案:

答案 0 :(得分:0)

json格式是键值对结构格式,因此json数据的最后部分不是适合json的格式,您必须提供一个键并将该值作为您获取的html

对于您的数据,应该是这样的

    {
    "draw": 1,
    "recordsTotal": 2,
    "recordsFiltered": 2,
    "data": [
        ["63", "emma", "+256702270442", "$0", " <a type=\"button\" class=\"btn editbutton\" title=\"Edit\" data-toggle = \"modal\" data-id=\"63\"><i class=\"fa fa-edit\"> <\/i> Edit<\/a>  <a type=\"button\" class=\"btn detailsbutton inffo\" title=\"Info\" data-toggle = \"modal\" data-id=\"63\"><i class=\"fa fa-info\"> <\/i> Info<\/a> <a class=\"btn green\" title=\"History\" style=\"color: #fff;\" href=\"patient\/medicalHistory?id=63\"><i class=\"fa fa-stethoscope\"><\/i> History<\/a> <a class=\"btn invoicebutton\" title=\"Payment\" style=\"color: #fff;\" href=\"finance\/patientPaymentHistory?patient=63\"><i class=\"fa fa-money-bill-alt\"><\/i> Payment<\/a> <a class=\"btn delete_button\" title=\"Delete\" href=\"patient\/delete?id=63\" onclick=\"return confirm('Are you sure you want to delete this item?');\"><i class=\"fa fa-trash\"><\/i> Delete<\/a>"]
    ],
    "moredata": "<div style = \"border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;\" > <h4 > A PHP Error was encountered < \/h4> <p > Severity: Core Warning < \/p> <p > Message: Module \"SourceGuardian\"already loaded < \/p> <p > Filename: Unknown < \/p> <p > Line Number: 0 < \/p> <p > Backtrace:< \/p><\/div>"
}

PS:别忘了正确转义html数据!