When a key within the json object has hyphen, possibly it is causing an issue with Karate. Here is an example –
{
"id": "1234",
"type": "FICTION",
"attribute": {
"bookPrice": "10",
"authorName": {
"firstName": "Dean",
"lastName": "Jones"
},
"links": {
"get-book-by-id": {
"href": "/v1/books/1234",
"title": "get-book-by-id"
}
}
}
}
In this example, the key “get-book-by-id” is seperated by hyphen and when I try to travers to this element, I am getting an error something like below –
org.graalvm.polyglot.PolyglotException: ReferenceError: 'book' is not defined.