gpt4 book ai didi

api - 如何使用 postman 检查字段数据类型(仅)?

转载 作者:行者123 更新时间:2023-12-05 08:56:01 24 4
gpt4 key购买 nike

我正在使用 Postman 进行少数 API 验证,我想在其中验证响应中几个字段的数据类型(字符串/整数)。我不想检查字段值。例如:如果我收到类似如下的响应,我想检查 sign_in_count 是否始终返回整数数据类型。 :

    {
"data": {
"id": 274,
"age": null,
"email_id": "ojuuw@mailinator.com",
"email_verification_flag": true,
"ext_account": null,
"ext_authenticator": null,
"ext_user_id": null,
"firstname": "firstname",
"forgot_password_sent": null,
"gender": null,
"last_sign_in_at": null,
"last_sign_in_ip": null,
"region": "IN",
"registered_using": null,
"remember_created_at": null,
"reset_password_sent_at": null,
"reset_password_token": null,
"sign_in_count": 0
}
}

任何帮助,非常感谢..

谢谢

最佳答案

您需要使用 typeof 函数返回未计算的操作数的类型。

var body = JSON.parse(responseBody);
tests["sign_in_count is number"] = typeof(body.data.sign_in_count) === "number";
tests["firstname is string"] = typeof(body.data.firstname) === "string";

关于api - 如何使用 postman 检查字段数据类型(仅)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42973515/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com