无法在空手道中获取json数组的长度

时间:2020-08-04 18:01:32

标签: karate

有人可以帮忙吗?api.store.book [*]。author:未返回任何值。即使长度函数api.length()无法正常工作。但是,api.store.book [0]:返回了详细信息。下面是参考json

*def api = read('book.json')
    
    {
        "store": {
            "book": [
                {
                    "category": "reference",
                    "author": "Nigel Rees",
                    "title": "Sayings of the Century",
                    "price": 8.95
                },
                {
                    "category": "fiction",
                    "author": "Evelyn Waugh",
                    "title": "Sword of Honour",
                    "price": 12.99
                }]}}


        
   
   

1 个答案:

答案 0 :(得分:0)

请阅读文档:https://github.com/intuit/karate#get-short-cut

* def authors = $api.store.book[*].author
* print authors