简体   繁体   English

如何在空手道中将 Json Object 转换为 Json 数组?

[英]How can I convert to Json Object to Json Array in Karate?

I want to convert Json Object to Json Array in Karate to use 'match each' func.我想在空手道中将 Json Object转换为Json 数组以使用“匹配每个”功能。 I am getting to ('match each' failed, not a json array) error when I use match each func with Json Object.当我将每个函数与 Json Object 一起使用时,我遇到了('匹配每个'失败,而不是 json 数组)错误。

Here is My Json Object:这是我的 Json Object:

{
  { "a": "q"
    "b": "w",
    "c": "t"
  },
  { "a": "x"
    "b": "y",
    "c": "z"
  }
}

And here is what I need:这就是我需要的:

  [  
    {
     { "a": "q"
       "b": "w",
       "c": "t"
     },
     { "a": "x"
       "b": "y",
       "c": "z"
     }
   }
 ]

Try this approach, using embedded expressions: https://github.com/intuit/karate#embedded-expressions尝试这种方法,使用嵌入式表达式: https://github.com/intuit/karate#embedded-expressions

* def foo = { a: 1 }
* def list = [ '#(foo)' ]
* match each list == foo

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM