I am using JSON to send Ajax data. I am getting comma separated mobile number from the input text box.And, I am converting it into javascript array.
Below is my code:
var myarray = {};
myarray = this.model.get('mobileno').split(',');
Result : myarray : ["123", "4567"];
I am going to set the same value to my model like below:
this.model.set('mobileno',JSON.stringify(myarray ));
Then, the value becomes like below:
console.log(this.model.get('mobileno'));
Result : mobileno : "["123","4567"]"
So, my model become this.model.toJSON();
Result :Object {mobileno: "["123","4567"]}
Till here, everything is correct. after that I need to set this model to another model and doing stringfy will give me like Below:
anotherModel.set('data', this.model);
"data":{"mobileno":"[\"123\",\"456\"]"}
But, I need like "data":{"mobileno":["123","456"]}
Your help will be appreciated.