2

I got the following JSON

   {
   "response":{
      "id":"XYZ",
      "header":[
         {
            "nat":"1"
         }
      ],
      "summary":[
         {
            "recordCreationDate":"29-Aug-2018",
            "verificationTypeDescription":"Verified",
            "birthDate":"01-Feb-1981",
            "sex":"F",
            "title":"MRS",
            "forename":"TEST",
            "surname":"TEST"
         }
      ]
   }
}

and I would like to get the value of any field, for instance birthDate, without providing the full path. Reading this nice tutorial https://www.james-willett.com/rest-assured-gpath-json, I have manage to write this - NOT WORKING - code:

response.jsonPath().get("$.'**'.find(){node -> node.name() == 'birthDate'}");

What am I missing?

user3727540
  • 922
  • 3
  • 11
  • 30
  • In other words, how can I tell the parser to search for a node with a given name regardless its position in the DOM? According to the official documentation, I should be able to achieve that using **, but I am not sure that node.name() is the right way to do it. Any help would be greatly appreciated. – user3727540 Aug 27 '19 at 12:08
  • Any help from @anyone? – user3727540 Aug 28 '19 at 11:43
  • Gpath on Json does not support `depthFist(**)`, this only supports in XML: http://groovy-lang.org/processing-xml.html#_flexible_navigation_with_children_depthfirst_and_breadthfirst – Xiao May 14 '22 at 13:44

0 Answers0