Home › Forums › JavaScript › Loop through JSON data help needed..
- This topic is empty.
-
AuthorPosts
-
June 21, 2013 at 9:19 am #45728matthiscoParticipant
HI folks,
Can someone please tell me how I can get the url for each rendition/item of this json data?
{ “items” : [ { “renditions” : [ { “audioOnly” : false,
“controllerType” : “DEFAULT”,
“displayName” : “361_NHS-condomneg#Expert_UB-H264-1024.mov”,
“encodingRate” : 963000,
“frameHeight” : 576,
“frameWidth” : 1024,
“id” : 33388781001,
“referenceId” : null,
“remoteStreamName” : null,
“remoteUrl” : null,
“size” : 16553283,
“uploadTimestampMillis” : 1250021595080,
“url” : “/25938593001/25938593001_33388781001_361-NHS-condomneg-Expert-UB-H264-1024.mp4”,
“videoCodec” : “H264”,
“videoContainer” : “MP4”,
“videoDuration” : 137558
},
{ “audioOnly” : false,
“controllerType” : “DEFAULT”,
“displayName” : “361_NHS-condomneg#Expert_UB-H264-1024.mov”,
“encodingRate” : 571000,
“frameHeight” : 268,
“frameWidth” : 480,
“id” : 33388757001,
“referenceId” : null,
“remoteStreamName” : null,
“remoteUrl” : null,
“size” : 9810270,
“uploadTimestampMillis” : 1250021535074,
“url” : “/25938593001/25938593001_33388757001_361-NHS-condomneg-Expert-UB-H264-1024.mp4”,
“videoCodec” : “H264”,
“videoContainer” : “MP4”,
“videoDuration” : 137558
},I’m currently trying to use:
for (var i=0; i
; alert(it.url);
}
But keep getting ‘undefined’, can anyone please help?
Thankyou
June 21, 2013 at 9:35 am #139740oprom3MemberDid you parse the JSON data first? Try:
var jsonObject = JSON.parse(jsonData);
for (var i =0; i < jsonObject.renditions.length; i++) {
alert(jsonObject.renditions.url);
}June 21, 2013 at 9:45 am #139742matthiscoParticipantThanks very much for your reply!
I have tried but get an error:
Error: SyntaxError: JSON.parse: unexpected character
June 26, 2013 at 9:00 am #140496matthiscoParticipantThanks for the reply.
Thats not all the data, there is quite a bit more.
I still get an error with this line:
Timestamp: 6/26/2013 2:00:02 PM
Error: SyntaxError: JSON.parse: unexpected character
Line: 39var jsonObject = JSON.parse(jsonData);
Can anyone please help? My json data is valid I have validated it.
Thankyou
July 5, 2013 at 4:50 am #141638matthiscoParticipantHello there,
I’m still struggling to get this working, can anyone please help me output the items?
Here is the json url:
http://api.brightcove.com/services/library?command=find_all_videos&video_fields=renditions&token=ZpwKJFMptqRXV-rtn5ZAuWfUYHgnHOQLmHltN90f9WZ7pde7raxS2w..&callback=response&noCacheIE=1371815630456
Many thanks
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.