how to convert json values in comma separated string using javascript

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

I have following JSON string :

8条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-18 07:16

    var json = [{"name":"Marine Lines","location_id":3},{"name":"Ghatkopar","location_id":2}];
    
    var locationIds = [];
    for(var object in json){
      locationIds.push(json[object].location_id);
    }
    
    console.log(locationIds.join(","));

提交回复
热议问题