我需要将下面 JSON 中的用户名与 Mule ESB 3.8.3 中的 flowVars 进行比较
{"id":"users_0001","username":"0001","firstName":"AB","lastName":"C","email":"abc@abc.com","enabled":true}
在选择运算符中使用此表达式
<choice doc:name="Choice">
<when expression="#[json:[0]/username != flowVars.username]">
<flow-ref name="put account" doc:name="put account"/>
</when>
<otherwise>
<flow-ref name="do nothing" doc:name="do nothing"/>
</otherwise>
</choice>
在调试过程中,我可以看到 json:[0]/username 和 flowVars.username 都返回相同的值,但是为什么在比较它们时总是返回 false?
这是我评估它们时的结果
flowVars.username == "0001", returns true
flowVars.username == '0001', returns true
flowVars.username == 0001, returns true
json:[0]/username = 0001, returns true
json:[0]/username = "0001", returns false
json:[0]/username = '0001', returns false
json:[0]/username != flowVars.username, returns true
json:[0]/username = flowVars.username, returns false