Support Questions

Find answers, ask questions, and share your expertise

Who agreed with this solution

avatar
Master Guru

The following configuration of ReplaceText should work for you:

16496-replacetext-1-element-array.png

where the Search Value is the following:

[\[\]](\{|\})

This matches [{ or ]} (and also [} and ]{ which shouldn't show up if your input is valid JSON) and replaces it with whichever curly brace it found. Note that this is a fairly specific solution, where the array is the last element of an object (i.e. the end pattern is not the end-of-object followed by end-of-array, rather the reverse).

A more forgiving solution (for your input JSON) might be to use the following Chain spec in a JoltTransformJSON processor:

[
  {
    "operation": "shift",
    "spec": {
      "result": {
        "curves": {
          "*": {
            "@": "result.curves"
          }
        },
        "*": "result.&"
      },
      "*": "&"
    }
  }
]

This "hoists" the object in the 1-element array up one level, achieving the same result as the ReplaceText pattern above.

View solution in original post

Who agreed with this solution