jQuery: Convert string with comma separated values to specific JSON format

前端 未结 4 1337
情歌与酒
情歌与酒 2020-12-30 08:38

I\'ve been losing hours over something that might be trivial:

I\'ve got a list of comma-separated e-mail addresses that I want to convert to a specific JSON format,

4条回答
  •  情歌与酒
    2020-12-30 08:47

    Try changing the loop to this:

        var JSON = [];
        $(pieces).each(function(index) {
            JSON.push({'email': pieces[index]});   
        });
    

提交回复
热议问题