I am trying to fetch the first node value (ResourceItemID i.e 2290) from my JSON response. My Response is look like :
{
"Success": true,
"TotalRecords": 41,
"RoomSearchResult": [
{
"ResourceItemID": 2290,
"Name": "Room 23 (L02)",
"LocationId": 7,
"GroupID": 518,
"FloorID": 2,
"DefaultCapacity": 4,
"CanBeBooked": true
},
{
"ResourceItemID": 2063,
"Name": "Room 15 (L10)",
"LocationId": 7,
"GroupID": 518,
"FloorID": 10,
"DefaultCapacity": 8,
"CanBeBooked": true
}
],
"Error": {
"ErrorCode": 0,
"ErrorDescription": ""
}
}
What i tried so far :
import groovy.json.JsonSlurper
def parsed = new JsonSlurper().parseText(json).find().value.RoomSearchResult.ResourceItemID
ResourceItemIDwhen condition is matched.2290a fixed value that you are looking for?