I've been toying with idea of using JSON for my final working applicatation but am having a little trouble getting my head round it all.
I've been reading this link
I'm a bit confused over this command
If I had sub set records within the object, how would I know?
I'm assuming from this that after parsing the JSON, myObject would be an array for each master record with the following syntax
etc.
But what if fldname3 was a sub record set?
How do I test for existing records or if there are no records, how do you build the JSON data to show it should be a sub set of records but not necessarily containing any sub records.
I'm guessing you could do something like this to access it, but am unsure how I build the data structure to start with.
Am I on the right track?
Cheers
1DMF
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Google Rank Extractor -> Perl beta with FusionCharts
I've been reading this link
I'm a bit confused over this command
Code:
var myObject = JSON.parse(myJSONtext, reviver);
If I had sub set records within the object, how would I know?
I'm assuming from this that after parsing the JSON, myObject would be an array for each master record with the following syntax
Code:
document.write(myObject[0].fldname1);
document.write(myObject[0].fldname2);
document.write(myObject[1].fldname1);
document.write(myObject[1].fldname2);
But what if fldname3 was a sub record set?
How do I test for existing records or if there are no records, how do you build the JSON data to show it should be a sub set of records but not necessarily containing any sub records.
I'm guessing you could do something like this to access it, but am unsure how I build the data structure to start with.
Code:
if (myObject[RecID].fldname3.length > 0){
for (i=0; i<myObject[RecID].fldname3.length; i++)
{
document.write(myObject[RecID].fldname3[i].fldname1);
document.write(myObject[RecID].fldname3[i].fldname2);
document.write(myObject[RecID].fldname3[i].fldname3);
}
}
Am I on the right track?
Cheers
1DMF
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Google Rank Extractor -> Perl beta with FusionCharts