空手道:如果对象名在数组中包含句点,如何设置Json值

空手道:如果对象名在数组中包含句点,如何设置Json值,json,parameter-passing,karate,Json,Parameter Passing,Karate,这是我的JSON请求示例代码,正如您所看到的,#(parametrvale)将被MyValue替换 Below is the example of the request json and code: * request """ { "query": { "bool": { "must": [ { "

这是我的JSON请求示例代码,正如您所看到的,#(parametrvale)将被MyValue替换

Below is the example of the request json and code:
            * request 
    """
            {
          "query": {
            "bool": {
              "must": [
                {
                  "match_data": {
                    "Event.Data.message": "#(Paramtervale)"
                  }
                },
                {
                  "match_data": {
                    "Event.Name": "#(Paramtervale2)"
                  }
                }
              ],
              "filter": {
                "range": {
                  "@timestamp": {
                    "gte": "now-1m"
                  }
                }
              }
            }
          }
        }
            """
* set request.Event.Data.message = myvalue
* set request.{Event.Data.message} = myvalue
* set request.(Event.Data.message) = myvalue

以上这些都不起作用,请任何人提供帮助,这里有两种不同的方法,请注意,对于更新JSON,
set
不再需要了。如果键名中有特殊字符,请使用方括号方法引用JSON数据:

* def temp = { 'a.b': 'xxx' }
* temp['a.b'] = 'yyy'
* match temp == { 'a.b': 'yyy' }

# using embedded expressions
* def val = 'yyy'
* def temp = { 'a.b': '#(val)' }
* match temp == { 'a.b': 'yyy' }
示例代码:

Feature: Validation

    Scenario:
        * def req =
            """
            {
                "query": {
                    "bool": {
                        "must": [
                            {
                                "match_data": {
                                    "Event.Data.message": "#(Paramtervale)"
                                }
                            },
                            {
                                "match_data": {
                                    "Event.Name": "#(Paramtervale2)"
                                }
                            }
                        ],
                        "filter": {
                            "range": {
                                "@timestamp": {
                                    "gte": "now-1m"
                                }
                            }
                        }
                    }
                }
            }
            """
        * req.query.bool.must[0].match_data["Event.Data.message"] = "abc"
        * req.query.bool.must[1].match_data["Event.Name"] = "def"
        * print req

*请求['Event.Data.message']=logDataMessage正在部分工作。作为“Event.Data.message”追加结尾的参数和值为“MyValue”,因此请求出错。该值在实际中被替换,并且在请求的末尾附加相同的值。like read('classpath:'query.json')