我希望将一个字符串拆分成单独的字符,但是很难使DTL正确。
我有:
"foo":"bar"我希望
"foo":["b","a","r"]发布于 2017-12-05 07:42:49
您可以使用"range“和"substring”来解决这个问题。表现可能不太好。
{
  "_id": "split-word",
  "type": "pipe",
  "source": {
    "type": "embedded",
    "entities": [{
      "_id": "baz",
      "foo": "bar"
    }]
  },
  "transform": {
    "type": "dtl",
    "rules": {
      "default": [
        ["add", "foo",
          ["map",
            ["substring",
              "_.", ["plus", "_.", 1], "_S.foo"],
            ["range", 0,
              ["length", "_S.foo"]
            ]
          ]
        ]
      ]
    }
  }
}给出以下结果:
[
  {
    "_id": "baz",
    "foo": [
      "b",
      "a",
      "r"
    ]
  }
]https://stackoverflow.com/questions/47634910
复制相似问题