Karate 空手道-用if条件替换值
我有以下json。如果a==“hello”,我想用“Türkice”替换“Türkiye”。请帮助我指导添加替换为if条件组合Karate 空手道-用if条件替换值,karate,Karate,我有以下json。如果a==“hello”,我想用“Türkice”替换“Türkiye”。请帮助我指导添加替换为if条件组合 * def a = "hello" * def expected = """ { "_": { "country-language-list": { "country-language": [ {
* def a = "hello"
* def expected =
"""
{
"_": {
"country-language-list": {
"country-language": [
{
"_": "English",
"@": {
"languageCode": "en"
}
},
{
"_": "Deutsch",
"@": {
"languageCode": "de"
}
},
{
"_": "Türkiye",
"@": {
"languageCode": "tr"
}
}
]
}
},
"@": {
"countryCode": "TR"
}
}
"""
给你:
* if (a == 'hello') expected._['country-language-list']['country-language'][2]._ = 'Türkice'
给你:
* if (a == 'hello') expected._['country-language-list']['country-language'][2]._ = 'Türkice'
多谢。这起作用了。这里有一个澄清,我们添加[]是因为键中有特殊的字符“-”吗?是的,我尝试不使用这些键,但它不起作用。我试着用不带特殊字符“-”的名字来更改键,结果成功了。谢谢学到了一些新东西:)谢谢。这起作用了。这里有一个澄清,我们添加[]是因为键中有特殊的字符“-”吗?是的,我尝试不使用这些键,但它不起作用。我试着用不带特殊字符“-”的名字来更改键,结果成功了。谢谢学到了一些新东西:)