JSON JDT替换转换不起作用

时间:2018-12-13 21:11:30

标签: json transformation devops

我正在尝试转型

 { "outputs": [
{ "type": "Sample" },
{
  "type": "Sample1",
  "indexNamePrefix": "Sample2",
  "serviceUri": "Sample3",
  "eventDocumentTypeName": "Sample4"
}
]
}

变成这样

{ "outputs": [
{ "type": "Sample" },
{
 "type": "Sample1",
 "indexNamePrefix": "Sample2",
 "serviceUri": "NewValue",
 "eventDocumentTypeName": "Sample4"
}
]
}

我已经根据您的示例尝试了几次转换  尝试1:  我只是试图替换serviceUri这是唯一的更改,以下是转换

  {
     "outputs": {
     "@jdt.replace": {
      "@jdt.path": "@[?(@.serviceUri == Sample3)]",
      "@jdt.value": {
        "serviceUri": "NewValue"
      }
    }
    }
    }

结果类似于以下内容,类似于转换,并且看起来转换没有发生

{
 "outputs": {
    "@jdt.replace": {
      "@jdt.path": "@[?(@.serviceUri == Sample3)]",
      "@jdt.value": {
        "serviceUri": "NewValue"
      }
    }
}

尝试2:  我试图替换整个输出节点

{
  "outputs": {
    // Double brackets are needed to specify
    // the array as the transformation value
    "@jdt.replace": [
      [
        {
          "type": "Sample"
        },
        {
          "type": "Sample1",
          "indexNamePrefix": "Sample2",
          "serviceUri": "NewValue",
          "eventDocumentTypeName": "Sample4"
        }
      ]
    ]
  }
}

结果也与此处的转换相同,我是否缺少某些内容?因为基本的删除和重命名转换工作正常。

这是我关注的链接https://github.com/Microsoft/json-document-transforms

预先感谢

0 个答案:

没有答案