0

I am trying to use JSONPath expression to extract 2 arrays and concatenate them today to form a long array - and ideally making them unique. However, no syntax I use in the online playground produces results. Ultimately I will want to use this in a Jenkins job. So, it has to be operational with the Java implementation

Here is my json

{
  "commits": [
    {
      "author": {
        "name": "Christian",
        "email": "christian@company.com"
      },
      "added": [
        "deleteme/main.tf"
      ],
      "modified": [

      ],
      "removed": [
        "deleteme.txt"
      ]
    }
  ]
}

And here is my expression (which I am trying to evaluate here):

$.append($.commits[*].added[*], $.commits[*].removed[*])

Which I would love to see as

["deleteme/main.tf", "deleteme.txt"]

Or better still:

"deleteme/main.tf, deleteme.txt"

because ultimately I need a comma separated set of values

Oh yeah: Bonus for only unique results

Christian Bongiorno
  • 5,150
  • 3
  • 38
  • 76

1 Answers1

1

JSON Path is a query language. Some tools have used it to enable transformation functionality, but this is not something that JSON Path itself generally supports.


Disclaimer and Open Specification Plug

The online tool you linked is not "official." There is no "official" tooling because there is no specification. Pretty much everyone has been building implementations from a 15yo blog post and adding their own features.

But there's good news: we're building a spec!

gregsdennis
  • 7,218
  • 3
  • 38
  • 71