how to convert json values in comma separated string using javascript

后端 未结 8 854
情话喂你
情话喂你 2021-01-18 06:29

I have following JSON string :

8条回答
  •  执笔经年
    2021-01-18 07:22

    obj=[{"name":"Marine Lines","location_id":3}, {"name":"Ghatkopar","location_id":2}]
    var res = [];
    for (var x  in obj)
    if (obj.hasOwnProperty(x))
        res.push(obj[x].location_id);
    console.log(res.join(","));

提交回复
热议问题