S
samseed
Hi, I have a delimited string that I would like to load into a data
object. Here is what I have so far:
//single string of data; each record is delimited by "%"
//and each value within each record is delimited by ";"
var myString = "foo1;001;bar1%foo2;002;bar2%foo3;003;bar3%";
//split each record into an array
var myRecords = myString.split("%");
Now that I have each record in an array, I need to load each array
element into a data object property as follows:
myData[0] = {prop1:"foo1",prop2:"001",prop3:"bar1"};
myData[1] = {prop1:"foo2",prop2:"002",prop3:"bar2"};
myData[2] = {prop1:"foo3",prop2:"003",prop3:"bar3"};
Is there a way to go from the string straight to the data object, or
should I use the above process? How can I split each array element into
3 properties for the data object? Thanks.
object. Here is what I have so far:
//single string of data; each record is delimited by "%"
//and each value within each record is delimited by ";"
var myString = "foo1;001;bar1%foo2;002;bar2%foo3;003;bar3%";
//split each record into an array
var myRecords = myString.split("%");
Now that I have each record in an array, I need to load each array
element into a data object property as follows:
myData[0] = {prop1:"foo1",prop2:"001",prop3:"bar1"};
myData[1] = {prop1:"foo2",prop2:"002",prop3:"bar2"};
myData[2] = {prop1:"foo3",prop2:"003",prop3:"bar3"};
Is there a way to go from the string straight to the data object, or
should I use the above process? How can I split each array element into
3 properties for the data object? Thanks.