空手道 - 用 if 条件替换值
Karate - Replace a value with if condition
我有以下json。如果 == “hello”,我想用 'Türkice' 替换 'Türkiye'。请帮助我指导添加替换为 if 条件组合
* 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'
我有以下json。如果 == “hello”,我想用 'Türkice' 替换 'Türkiye'。请帮助我指导添加替换为 if 条件组合
* 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'