本文介绍了空手道:匹配两个不同JSON的数组元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下两个响应,我需要检查res1.member.part[0].supportedMembers[*].muid == res2.membersSupported[*].member.muid
(元素的顺序不相同).尝试了不同的方法,但没有任何结果适合我.任何帮助将不胜感激!
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"}]}}]}
推荐答案
在这里:
* match res1.part[1].supportedMembers[*].muid contains only $res2.members[*]..muid
还请注意,在某些情况下,您可以使用..
简化操作.
Also note that you can use ..
to simplify things in some cases.
这篇关于空手道:匹配两个不同JSON的数组元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!