JSON file jsonExample
:
{
\"store\": {
\"book\": [
{
\"category\": \"fiction\",
\"author\": \"Evelyn Waugh\",
I don't understand why you are so concerned with this. Wildcards will not work for updating JSON. It is that simple.
And one more thing, eval
will work with pure JS only. Json-Path is NOT pure JS.
Maybe this will explain it more clearly.
If * set jsonExample $..book[0].something = 13
is working please assume that it is a BUG. Do not rely on it. It may work in this case because the code is resilient as far as possible. But it may not work in other cases or in future versions of Karate.
All the below will work:
* def jsonExample =
"""
{
"store": {
"book": [
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"something": 12.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
},
"expensive": 10
}
"""
# all these will work
* set jsonExample $.store.book[0].something = 13
* match jsonExample.store.book[0].something == 13
* set jsonExample.store.book[0].something = 14
* match jsonExample.store.book[0].something == 14
* eval jsonExample.store.book[0].something = 15
* match jsonExample.store.book[0].something == 15
I really hope this makes it clear !!