Note that there are some explanatory texts on larger screens.

plurals
  1. POSplicing YouTube feed JSON result
    text
    copied!<p>Say I have the following (phoney) feed result from YouTube using the Google Feed API.</p> <pre><code>{ "feed" : { "author" : "YouTube", "description" : "", "entries" : [ { "author" : "Foo", "categories" : [ "http://gdata.youtube.com/schemas/2007#video", "Entertainment", "golf", "resort" ], "content" : "Four friends are playing golf. Originally aired on 3/22/2011.", "contentSnippet" : "Four friends are still playing golf. Originally aired on ...", "link" : "http://www.linktoyoutubevid.com", "publishedDate" : "Thu, 24 Mar 2011 07:07:13 -0700", "title" : "Foobar" }, .....more feed entries here..... ], "feedUrl" : "http://www.myyoutubefeed.com", "link" : "http://www.youtube.com", "title" : "YouTube Videos", "type" : "atom10" }, "m" : "json", "status" : { "code" : 200 } } </code></pre> <p>I want to save this feed result (keeping the JSON format) to a variable, but I first want to strip out elements like categories, content, and contentSnippet. I tried using .splice but kept getting this error: Error: <code>feedResult.feed.entries[0].splice is not a function</code></p> <p>Here's part of my feed call:</p> <pre><code>feedUrl: opts.sourceUrl, type: "video", numEntries: 3, onFeedLoad: function(feedResult) { //alert(feedResult); formatVids(feedResult); var test = feedResult.feed.entries[0].splice(1,3); //alert(test); </code></pre> <p>What's the correct way to use .splice in this scenario? I could be getting confused as to whether I need to be splicing a JSON string or the JSON object. Is there a better solution?</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload