JSON测试错误

时间:2018-08-02 08:25:56

标签: json api testing automation postman

JSON文件响应正文:

{
    "Concurr": {
        "BPhoneNumber": null,
        "Agility": 1,
        "Email": "abcde@gg.com",
        "FirstName": "DIK",
        "LastName": "BO",
        "PhoneNumber": "03456778",
        "PhoneType": "",
        "PostalAddress": {
            "Address1": "47 ILZ RUE KLI EBRELES",
            "Address2": null,
            "Address3": null,
            "City": "OOL",
            "Country": "250",
            "Zip": "9760"
        },
        "PNSCode": ""
    },
    "DealID": 2,
    "ObjID": null,
    "OrderM": "IOPL",
    "Parts": [],
    "Product": {
        "ComRef": "IKOL341JKL        ",
        "PurchaseDate": "2018-07-12T06:31:13.053",
        "SerialNumber": "9501123456",
        "TRef": "S51M50X2EU/03"
    },
    "StNas": [
        {
            "AppointmentDate": "2018-08-02T10:03:27.8737443+02:00",
            "AppointmentRank": null,
            "Code": "100",
            "Comment": "",
            "Parts": []
        },
        {
            "AppointmentDate": "2018-08-02T10:03:27.8737443+02:00",
            "AppointmentRank": null,
            "Code": "1101",
            "Comment": "",
            "Parts": []
        }
    ],
    "SCode": null,
    "VID": 10
}

通过https://jsonschema.net生成模式后,我正在使用

验证模式
var data = JSON.parse(responseBody);
tests["Valid scehma"] = tv4.validate(data, schema);

这总是给我邮递员一个错误,

There was an error in evaluating the test script : Cannot read property 'id' of null

任何人都可以帮助您了解导致此错误的原因或对此问题有任何解决方案/感谢您的帮助

1 个答案:

答案 0 :(得分:0)

ObjID": null编辑为整数后,该问题被撤消。