空手道-用if条件替换一个值

问题描述

我有以下json。如果==“ hello”,我想将'Türkiye'替换为'Türkice'。请帮助我,提供以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'