var oSamples = new Samples();
//Samples Object
function Samples() {
this.sampleID = new Array();
this.oSampleGroup = new SampleGroup();
this.iSampleCount = 0;
this.sampleName = new Array();
}
//SampleGroup Object
function SampleGroup() {
this.oSample = new Array();
this.iSampleCount = 0;
this.addSample = function(barcode, date, time, collectedAt) {
this.oSample[this.iSampleCount] = new Sample(barcode, date, time, collectedAt);
this.iSampleCount += 1;
}
}
// add a sample
function Sample(barcode, date, time, collectedAt){
this.sCarcode = barcode;
this.dDate = date;
this.sTime = time;
this.sCollectedDateTime = collectedAt;
}
JSON.stringify(oSamples);
上面的示例对象的严格内容在sampleGroup对象中不包含addSample方法。