function test(){
if(this === null){
console.log("This is null");
}else{
console.log("This is Object");
}
}
test.call(null);
test.call({});
Run Code Online (Sandbox Code Playgroud)
输出:
这是对象.
这是对象.
但我期待输出:
这是空的.
这是对象.
为什么Null没有设置在上下文中?
我尝试使用 JSON 模式检查用户详细信息对象。但我不知道如何在 Java 中检查 JSON 对象。
我的架构:
{
"type" : "object",
"properties" : {
"first_name" : {
"type" : "string" ,
"minLength" : 3 ,
"maxLength" : 255
},
"last_name" : {
"type" : "string" ,
"minLength" : 3 ,
"maxLength" : 255
},
"age" : {
"type" : "integer" ,
"minimum" : 16 ,
"maximum" : 40
},
"phone_number" : {
"type" : "integer",
"pattern" : "[6-9][0-9]{9}"
} ,
"email" : {
"type" : "string",
"pattern" : "[a-z0-9]+" …Run Code Online (Sandbox Code Playgroud)