JCK
JCK

Reputation: 129

Karate: Match array elements of two different JSON

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"}]}}]}

Upvotes: 1

Views: 253

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58058

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.

Upvotes: 1

Related Questions