我想将用户输入转换为对象 例如:如果用户输入输入框: {id:11,pId:1,name:" xyz" }, {id:111,pId:11,name:" abc" }
转换为2个对象
答案 0 :(得分:0)
这是我的例子:
$(“#generate”)。click(function(){
if ($("#jsonData").val() == "") {
zNodes = [
{ id: 1, pId: 0, name: "LEVEL 1", expand: false },
{ id: 11, pId: 1, name: "ClientSide" }
];
}
if ($("#jsonData").val() !== "") {
//i want from user to enter the data
var a = $("#jsonData").val();
var b = {a};
zNodes = [b];
}