如何检查此Json响应是否为null

How to check this Json response whether its null or not

本文关键字:响应 Json 是否 null 何检查 检查      更新时间:2023-09-26
{"PatientPastMedicalHistoryGetResult":{"PastMedicalHistory":[]}}

PastMedicalHistory数组为NUll,没有值。如何检查。

if (response.PatientPastMedicalHistoryGetResult.PastMedicalHistory.length == 0) {
}

这不是空的。这是一个空数组。

如果响应为null,请尝试

   var data = {"PatientPastMedicalHistoryGetResult":{"PastMedicalHistory":[]}};
    for (member in data) {
        if (data[member] != null)
            // Do work here
    }