Karate: Match array elements of two different JSON

假如想象 提交于 2020-03-03 14:00:00

问题


I have the below two responses, I need to check whether the res1.member.part[0].supportedMembers[*].muid == res2.membersSupported[*].member.muid (order of the elements are not same). Tried out different things but nothing is working out for me. Any help would be greatly appreciated!

* def res1 = {"member":{"muid":"MBR1"},"part":[{"PID":"M123"},{"supportedMembers":[{"muid":"MBR3","status":{"code":"A"}},{"muid":"MBR2","status":{"code":"I"}}]}]}

* def res2 = {"members":[{"member":{"muid":"MBR2","test":[{"EID":"E123"}]}},{"member":{"muid":"MBR3","test":[{"EID":"E123"}]}}]}

回答1:


Here you go:

* match res1.part[1].supportedMembers[*].muid contains only $res2.members[*]..muid

Also note that you can use .. to simplify things in some cases.



来源:https://stackoverflow.com/questions/60402036/karate-match-array-elements-of-two-different-json

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!