英文:
how to send undefined value in postman?
问题
{
"a": [undefined, {"b": "ball", "c": "cat"}]
}
英文:
Is there a way to send something like this in postman?
{
"a": [undefined, {"b":"ball", "c":"cat"}]
}
Postman gives a red underline under undefined
. If I use the pre-request script to pm.variables.set('undefinedVariable', undefined);
and use this, then my code is giving this error
{
"statusCode": 400,
"error": "Bad Request",
"message": "Invalid request payload JSON format"
}
答案1
得分: 3
与node.js或postman无关。 undefined
不是一个有效的JSON值,尽管在JavaScript中是有效的。 你可能可以使用null
来代替。
来自官方JSON标准(ECMA-404,第5节)的说明:
undefined 不是一个有效的JSON值,尽管在JavaScript中是有效的。
一个JSON值可以是对象、数组、数字、字符串、true、false或null。
英文:
It has nothing to do with node.js nor postman. undefined
is not a valid json value even though it is valid in javascript. You may be able to use null
instead
https://stackoverflow.com/a/14946821/6785908
> - undefined is not a valid JSON value, even though it is valid in javascript.
>
> From the official JSON
> standard
> (ECMA-404, Section 5):
>
> > A JSON value can be an object, array, number, string, true, false, or null.
答案2
得分: 2
你需要在JSON中使用null代替undefined,因为JSON不支持undefined关键字。示例:
{
"a": [null, {"b": "ball", "c": "cat"}]
}
英文:
You need to define null in place of undefined as JSON doesn't handle undefined keyword. Example:
{
"a": [null, {"b":"ball", "c":"cat"}]
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论