Simple:

var data = [{"name":"Marine Lines","location_id":3},{"name":"Ghatkopar","location_id":2}]
var result = data.map(function(val) {
  return val.location_id;
}).join(',');

console.log(result)

I assume you wanted a string, hence the .join(','), if you want an array simply remove that part.

Answer from Chrillewoodz on Stack Overflow
🌐
OneCompiler
onecompiler.com › javascript › 3xfqsme8y
convert a json array of objects to comma separated values - JavaScript - OneCompiler
Executable in both browser and server which has Javascript engines like V8(chrome), SpiderMonkey(Firefox) etc. var readline = require("readline") var rl = readline.createInterface({ input: process.stdin, output: process.stdout, terminal: false, }) rl.on("line", function (line) { console.log("Hello, " + line) }) ... An array is a collection of items or values.
Discussions

JavaScript: How to get comma separated string from json string? - Stack Overflow
I have a JSON string value that corresponds to this object: { "id" : "122223232244", "title" : "התרעת פיקוד העורף", "data" : ["עוטף עזה 218","עוטף עזה 217"] } I am trying to extract the following... More on stackoverflow.com
🌐 stackoverflow.com
June 13, 2019
Json to array comma
Hello everyone. I trying to convert a json data to a string comma separated. Json is like this one: [ { "id": "625d757724acbe52634e6172", "idBoard": "625850ac4247c214ff3dc167", "name": "ANGELIS", "color": "yellow" }, { "id": "625d57da6bfa728b6684ed43", "idBoard": "625850ac4247c214ff3dc167", ... More on community.n8n.io
🌐 community.n8n.io
0
0
May 16, 2022
javascript - Convert string separated by comma in json object to array - Stack Overflow
I want to convert this json object that contain string value separated by comma to array: [ {id: 1, name: 'book', colors: 'red, yellow, blue' }, id: 2, name: 'book', colors: 'red, yel... More on stackoverflow.com
🌐 stackoverflow.com
javascript - Get comma separated string from array - Stack Overflow
Is it correct to assume you made a typo and what you want is one string instead of several comma-separated strings? ... why do you want to convert a JSON array (with is supported by the JSON format) to a comma separated string? I can't think of a good reason to do it. More on stackoverflow.com
🌐 stackoverflow.com
May 24, 2017
🌐
Experts Exchange
experts-exchange.com › questions › 28652216 › How-to-get-convert-json-array-to-comma-separated-values.html
Solved: How to get convert json array to comma separated values | Experts Exchange
April 8, 2015 - What exception do you get and what JSONTokener are you using ? http://www.massapi.com/class/js/JSONTokener-1.html#Example6 And I believe this should work · String input ='[{"filter":"ID","filterValues":["050886","050885","050884","050883","050882"]}]'; JSONArray jsonarray = (JSONArray) new JSONTokener(input ).nextValue(); for (int i = 0; i < jsonarray.length(); i++) { JSONObject jsonobject = jsonarray.getJSONObject(i); String field= jsonobject.getString("filter"); String values= jsonobject.getJSONObject("filterValues"); }
🌐
n8n
community.n8n.io › questions
Json to array comma - Questions - n8n Community
May 16, 2022 - Hello everyone. I trying to convert a json data to a string comma separated. Json is like this one: [ { "id": "625d757724acbe52634e6172", "idBoard": "625850ac4247c214ff3dc167", "name": "ANGELIS", "color": "yellow" }, { "id": "625d57da6bfa728b6684ed43", "idBoard": "625850ac4247c214ff3dc167", ...
🌐
ServiceNow Community
servicenow.com › community › developer-forum › convert-array-string-to-comma-separated-string › m-p › 2606171
Convert Array String to Comma Separated String - ServiceNow Community
July 6, 2023 - Hi, I suspect your issue is that your array is an array of objects, and so may need to iterate through the sorted array stringifying each element\object and concatenating these individually to your output string. ... var tempString = ''; for(key in sortedArray) { tempString = tempString + JSON.stringify(sortedArray[key]); }
Find elsewhere
🌐
Microsoft Power Platform Community
powerusers.microsoft.com › t5 › Building-Flows › JSON-received-as-a-comma-separated-string-need-help-in › td-p › 676482
https://powerusers.microsoft.com/t5/Building-Flows...
Quickly search for answers, join discussions, post questions, and work smarter in your business applications by joining the Microsoft Dynamics 365 Community.
🌐
Stack Overflow
stackoverflow.com › questions › 54230873 › transform-comma-separated-strings-to-json
javascript - Transform comma separated strings to JSON - Stack Overflow
4 convert string to json array · 11 jQuery: Convert string with comma separated values to specific JSON format · 0 how to convert json objects sepeted by comma into object · 2 Convert a JSON Object to Comma Sepearted values in javascript · 10 how to convert json values in comma separated string using javascript ·
🌐
Wappler Community
community.wappler.io › wappler general › need help
Show json array field as comma separated values - Need Help - Wappler Community
July 1, 2023 - I have a JSON field which stored days of the week. I want to show those in my list but it’s displaying them like this: ["Mon","Tue","Wed","Thu","Fri"] I’m sure it must be easy to change this but cannot find how. I wan…
🌐
Reddit
reddit.com › r/javascripttips › how do i convert an array to a string with commas in javascript
r/JavaScriptTips on Reddit: How do I convert an array to a string with commas in JavaScript
April 13, 2023 -

In JavaScript, you can convert an array to a string with commas using the join()
method.

The join() method returns a string that concatenates all the elements of an array, separated by the specified separator, which in this case is a comma.

Here is an example:

const array = ['apple', 'banana', 'orange'];
const string = array.join(', ');
console.log(string); 

// output: "apple, banana, orange"

In this example, we first define an array of three fruits. Then we use the join()
method with a comma and a space as the separator to create a string that lists all the fruits with a comma and a space between each one.

You can replace the comma and space separator with any other separator you like, such as a hyphen, a semicolon, or a newline character.

It's important to note that the join() method only works on arrays, and it will throw an error if you try to use it on any other type of object.

Click here to learn more ways to Convert Array to String with Commas in JS

🌐
W3Resource
w3resource.com › javascript-exercises › fundamental › javascript-fundamental-exercise-4.php
JavaScript fundamental (ES6 Syntax): Convert a comma-separated values string to a 2D array of objects - w3resource
July 3, 2025 - const CSV_to_JSON = (data, delimiter = ',') => { // Extract titles from the first row of the CSV data. const titles = data.slice(0, data.indexOf('\n')).split(delimiter); // Split the CSV data by newline characters, map each row to a JSON object with titles as keys. return data .slice(data.indexOf('\n') + 1) .split('\n') .map(v => { const values = v.split(delimiter); // Create a JSON object using titles and corresponding values. return titles.reduce((obj, title, index) => ((obj[title] = values[index]), obj), {}); }); }; // Test cases console.log(CSV_to_JSON('col1,col2\na,b\nc,d')); // [{'col1':
🌐
Stack Overflow
stackoverflow.com › questions › 49098104 › convert-json-values-in-comma-separated-string-using-javascript
convert json values in comma separated string using javascript - Stack Overflow
March 4, 2018 - Else if it is a string then you can parse it first using JSON.parse() and then do the same thing. var x = '{"name":"Marine Lines","name":"jerry"}'; x = JSON.parse(x); var name = x.name; console.log(name); ... Sign up to request clarification ...