CharlieCA
04-01-2010, 03:28 PM
Sorry if this question is basic but I haven't seem to run across anything that talks about how to add and remove data from a JSON object.
var work = { "days" : [
{ "date" : "3/1/2010",
"totalhours" : "6",
"jobs" : [
{ "hours" : "5",
"job_name" : "Clean"},
{ "hours" : "2",
"job_name" : "Cook"}
],
},
{ "date" : "3/2/2010",
"totalhours" : "2",
"jobs" : [
{ "hours" : "1",
"job_name" : "Wash"},
{ "hours" : "1",
"job_num" : "Scrub"}
],
}],
};
For example, how would I add a job to work.days[1].jobs or delete work.days[0].jobs[0]?
var work = { "days" : [
{ "date" : "3/1/2010",
"totalhours" : "6",
"jobs" : [
{ "hours" : "5",
"job_name" : "Clean"},
{ "hours" : "2",
"job_name" : "Cook"}
],
},
{ "date" : "3/2/2010",
"totalhours" : "2",
"jobs" : [
{ "hours" : "1",
"job_name" : "Wash"},
{ "hours" : "1",
"job_num" : "Scrub"}
],
}],
};
For example, how would I add a job to work.days[1].jobs or delete work.days[0].jobs[0]?