检查 json 属性 是否为空

Check if json property is null

我有以下输入

{
  "headers": {
   ...
},
  "body": {
    "RequestInfo": {
     ...
    ,
     "Identificator": null
        }
}

<filter regex="false" source="boolean($ctx:Identificator)"> -check if exist(when it's null it still viewed as existing.)

我正在创建检查标识符值的服务。

但在本例中为空。有人可以给我一个 xpath 中的示例,说明我应该如何进行检查,因为它是 null 而不是有效值吗?

编辑: 有人可以在 JavaScript 中告诉我如何获得标识符的值,因为这种方法行不通吗?

EDIT2:JS 有效,但事实证明,在 WSO2 中,当我们获得标识符时,null 被视为字符串,因此 ctx:Identificator='null' 也有效。

在 javascript 你可以这样做:

    let myJsonString = "{
       "headers": {
            ...
        },
       "body": {
           "RequestInfo": {
                ...,
               "Identificator": null
            }
        }
    }"
    const parsedJsonValue = JSON.parse(myJsonString);
    const {body} = parsedJsonValue;
    if(body && body.RequestInfo) {
        const {Identificator} = body.RequestInfo;
        if(Identificator === null || Identificator === undefined) {
            // Identificator is null
        }
    }

希望这就是您要找的东西