如何使用 Javascript / jQuery 将逗号分隔的列表转换为 json?
例如
转换以下内容:
var names = "Mark,Matthew,Luke,John,";
进入:
var jsonified = {
names: [
{name: "Mark"},
{name: "Mattew"},
{name: "Luke"},
{name: "John"}
]
};
如何使用 Javascript / jQuery 将逗号分隔的列表转换为 json?
例如
转换以下内容:
var names = "Mark,Matthew,Luke,John,";
进入:
var jsonified = {
names: [
{name: "Mark"},
{name: "Mattew"},
{name: "Luke"},
{name: "John"}
]
};