Forum Discussion

lzc's avatar
lzc
Occasional Contributor
10 years ago

validating that 2 json nodes are equal

Hi, we have the need to validate that 2 json nodes containing a batchid are equal. see attachment   this would seem to be very simple but yet we cannot get this to work properly.   i have tried ...
  • gilugopi's avatar
    10 years ago

    Not a 100% sure whether I understood your question. But try this..

    Can't see the full json path from your screenshot, so make sure you mention the full json path including the root node name in below variable assignments( example : def a = json.root_node.next_node.next_to_next_node )

     

     

    import groovy.json.JsonSlurper

     

    def json = new JsonSlurper().parseText(messageExchange.responseContent)
    def a = json.points[0].batchId
    def b = json.points[1].batchId

    assert a == b

     

    Good Luck!

     

    Regards,

    Gilu Gopi