The profiler results - using the same feed between both methods -
JSON
structuredata2()
51641 35612 87253 0.2950 0.1045 0.3996 1
strreplace()
35612 0 35612 0.1045 0.0000 0.1045 417
XML
structuredata()
77657 35542 113199 1.3676 0.1073 1.4749 1
strreplace()
35542 0 35542 0.1073 0.0000 0.1073 416
Parsing 208 content items. XML takes 1.4749, JSON takes 0.3996, so about 4 times faster to use json. In actual operation it's the difference between an execution timeout with about 330 items, and successfully parsing 500+ items without a timeout (2 seconds vs 5+ seconds).
XML parse code:
Function StructureData(Source As String) As Object
content=createObject("roSGNode","ContentNode")
contentxml=createObject("roXMLElement")
contentxml.parse(Source)
categories=contentxml.GetChildElements()
categorynames=[]
categorynames.Push(categories[0]@name)
row=CreateObject("RoSGNode","ContentNode")
row.Title=categorynames[0]
If (categories[0].GetChildElements())<>invalid
categoryitems=categories[0].GetChildElements()
y=categoryitems.count()-1
For z=0 To y
item=CreateObject("RoSGNode","ContentNode")
item.ContentID=categories[0].entry[z].ContentID[0].GetBody()
item.Title=strreplace(categories[0].entry[z].Title[0].GetBody(),"_"," ")
item.Title=strreplace(item.Title,".mp4","")
item.Description=categories[0].entry[z].Description[0].GetBody()
item.Rating=categories[0].entry[z].Rating[0].GetBody()
item.Length=categories[0].entry[z].Length[0].GetBody()
item.ReleaseDate=categories[0].entry[z].ReleaseDate[0].GetBody()
item.Directors=categories[0].entry[z].Director[0].GetBody()
temp=[]
temp.Push(categories[0].entry[z].Actor1[0].GetBody())
temp.Push(categories[0].entry[z].Actor2[0].GetBody())
temp.Push(categories[0].entry[z].Actor3[0].GetBody())
item.Actors=temp
item.SDPosterURL=categories[0].entry[z].ThumbSD[0].GetBody()
item.HDPosterURL=categories[0].entry[z].ThumbHD[0].GetBody()
temp=categories[0].entry[z].StreamURL[0].GetBody()
addURL=""
If left(temp,7)<>"http://"
If Left(temp,10)="Animaniacs" addurl="Cartoons/"
If Left(temp,9)="Bananaman" addurl="Cartoons/"
If Left(temp,21)="Battle_of_the_Planets" addurl="Cartoons/"
If Left(temp,21)="Dungeons_and_Dragons/" addurl="Cartoons/"
If Left(temp,10)="Gatchaman/" addurl="Cartoons/"
If Left(temp,11)="Gatchaman 2" addurl="Cartoons/"
If Left(temp,11)="Gatchaman 3" addurl="Cartoons/"
If Left(temp,9)="Iron_Man/" addurl="Cartoons/"
If Left(temp,19)="Pinky_and_the_Brain" addurl="Cartoons/"
If Left(temp,21)="Pirates_of_Dark_Water" addurl="Cartoons/"
If Left(temp,6)="Shorts" addurl="Cartoons/"
If Left(temp,11)="Speed_Racer" addurl="Cartoons/"
If Left(temp,11)="Thundercats" addurl="Cartoons/"
If Left(temp,6)="X-Men/" addurl="Cartoons/"
item.url="http://"+m.global.serverprefix.+"/root/DVD/"+addURL+temp
Else
item.url=temp
End If
item.Genre=categories[0].entry[z].Genre[0].GetBody()
item.EpisodeNumber=categories[0].entry[z].EpisodeNumber[0].GetBody()
item.StreamFormat="mp4"
If Len(item.EpisodeNumber)=0
ServerO=Left(item.url,LEN(item.url)-3)+"bif"
ServerP=Left(item.url,LEN(item.url)-4)+"-SD.bif"
ServerN="http://192.168.1.9/"
item.HDBifURL=strreplace(ServerO,"http://"+m.global.serverprefix+"/root/",ServerN)
item.SDBifURL=strreplace(ServerP,"http://"+m.global.serverprefix+"/root/",ServerN)
End If
item.Album=categories[0].entry[z].BookmarkBrian[0].GetBody() 'Brian's Bookmark As String
item.Artist=categories[0].entry[z].BookmarkErin[0].GetBody() 'Erin's Bookmark As String
row.AppendChild(item)
Next
End If
content.AppendChild(row)
Return content
End Function
JSON parse code:
Function StructureData2(Source As String) As Object
content=createObject("roSGNode","ContentNode")
contentxml=createObject("roXMLElement")
contentxml=parseJSON(Source)
row=CreateObject("RoSGNode","ContentNode")
row.title=strreplace(contentxml["category name"],"_"," ")
If contentxml.entry.count()>0
cd=contentxml.entry[0]
y=cd.count()-1
For z=0 To y
item=CreateObject("RoSGNode","ContentNode")
item.ContentID=cd[z].ContentID
item.Title=strreplace(cd[z].Title,"_"," ")
item.Title=strreplace(item.Title,".mp4","")
item.Description=cd[z].Description
item.Rating=cd[z].Rating
item.Length=cd[z].Length
item.ReleaseDate=cd[z].ReleaseDate
item.Directors=cd[z].Director
temp=[]
temp.Push(cd[z].Actor1)
temp.Push(cd[z].Actor2)
temp.Push(cd[z].Actor3)
item.Actors=temp
item.SDPosterURL=cd[z].ThumbSD
item.HDPosterURL=cd[z].ThumbHD
temp=cd[z].StreamURL
addURL=""
If left(temp,7)<>"http://"
If Left(temp,10)="Animaniacs" addurl="Cartoons/"
If Left(temp,9)="Bananaman" addurl="Cartoons/"
If Left(temp,21)="Battle_of_the_Planets" addurl="Cartoons/"
If Left(temp,21)="Dungeons_and_Dragons/" addurl="Cartoons/"
If Left(temp,10)="Gatchaman/" addurl="Cartoons/"
If Left(temp,11)="Gatchaman 2" addurl="Cartoons/"
If Left(temp,11)="Gatchaman 3" addurl="Cartoons/"
If Left(temp,9)="Iron_Man/" addurl="Cartoons/"
If Left(temp,19)="Pinky_and_the_Brain" addurl="Cartoons/"
If Left(temp,21)="Pirates_of_Dark_Water" addurl="Cartoons/"
If Left(temp,6)="Shorts" addurl="Cartoons/"
If Left(temp,11)="Speed_Racer" addurl="Cartoons/"
If Left(temp,11)="Thundercats" addurl="Cartoons/"
If Left(temp,6)="X-Men/" addurl="Cartoons/"
item.url="http://"+m.global.serverprefix.+"/root/DVD/"+addURL+temp
Else
item.url=temp
End If
item.Genre=cd[z].Genre
item.EpisodeNumber=cd[z].EpisodeNumber
item.StreamFormat="mp4"
item.Album=cd[z].BookmarkBrian 'Brian's Bookmark As String
item.Artist=cd[z].BookmarkErin 'Erin's Bookmark As String
row.AppendChild(item)
Next
End If
content.AppendChild(row)
Return content
End Function