JSON测试错误

问题描述 投票:0回答:1

JSON文件响应主体:

{
    "Concurr": {
        "BPhoneNumber": null,
        "Agility": 1,
        "Email": "[email protected]",
        "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);

这总是让我在Postman中出错

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

任何人都可以帮助理解或有任何关于导致此错误的问题的解决方案/任何帮助表示赞赏

json api testing automation postman
1个回答
0
投票

ObjID": null编辑为整数后解决问题。

© www.soinside.com 2019 - 2024. All rights reserved.