0
{
   "pull_request": {
     "patch_url": null,
   },
   "created_at": "2012-11-14T15:25:33Z",
   "comments": 0,
   "labels": [
     {
       "color": "ededed
     }
   ],
   "id": 8356941,
   "assignees": [
      {
        "login": "Paul",
        "id": 444
      },
      {
        "login": "Steve",
        "id": 222
       }
    ]

By JSON Query

assignees[*].login, getting below output.

["Paul","Steve"]

But required as comma separated string without quotes as below,

Paul, Steve

How to do this in JSON Query?

VLAZ
  • 26,331
  • 9
  • 49
  • 67

2 Answers2

0

You can use JSON.stringify as below:

JS

const obj = {
  "pull_request": {
    "patch_url": null,
  },
  "created_at": "2012-11-14T15:25:33Z",
  "comments": 0,
  "labels": [{
    "color": "ededed"
  }],
  "id": 8356941,
  "assignees": [{
      "login": "Paul",
      "id": 444
    },
    {
      "login": "Steve",
      "id": 222
    }
  ]
}
const myJSON = JSON.stringify(obj);
console.log(myJSON);

If you would like to get comma seperated string for the array it can be done using join()

const names = ["Paul","Steve"];
console.log(names.join(", "));
mk23
  • 1,257
  • 1
  • 12
  • 25
0

As long as your title "How to convert array to String" is right, this will work:

assignees[*].login.toString()
sandrooco
  • 8,016
  • 9
  • 48
  • 86