I have the following JSON format :-
{
"id": "102",
"brand": "Disha",
"book": [{
"slr": "EFTR",
"description": "Grammer",
"data": "TYR",
"rate": true,
"numberOfPages": 345,
"maxAllowed": "12",
"currentPage": 345
},
{
"slr": "EFRE",
"description": "English",
"data": "TYR",
"rate": true,
"numberOfPages": 345,
"maxAllowed": "12",
"currentPage": 345
},
{
"slr": "BGTR",
"description": "French",
"data": "TYR",
"rate": true,
"numberOfPages": 345,
"maxAllowed": "12",
"currentPage": 345
}]
}
I want to write the groovy code to get the book array and print it one by one and before that I need to count the array node for book also.
I have tried below code:-
def response = context.expand( '${book#Response}' );
def slurper = new JsonSlurper();
String inputJSON = slurper.parseText(response)
def strFinalValueToRead = "\$." + "book[0]"
def strActualValue = parse(inputJSON).read(strFinalValueToRead).toString()
log.info strActualValue
I am getting error as
com.jayway.jsonpath.InvalidJsonException: net.minidev.json.parser.ParseException: Unexpected End Of File.
Any help would be appreciated.