Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Loop through JSON data help needed..

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #45728
    matthisco
    Participant

    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

    #139740
    oprom3
    Member

    Did 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);
    }

    #139742
    matthisco
    Participant

    Thanks very much for your reply!

    I have tried but get an error:

    Error: SyntaxError: JSON.parse: unexpected character

    #140496
    matthisco
    Participant

    Thanks 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: 39

    var jsonObject = JSON.parse(jsonData);

    Can anyone please help? My json data is valid I have validated it.

    Thankyou

    #141638
    matthisco
    Participant

    Hello 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

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.