1

I figured out the issue.. and I am still having issues.. here is how the JSON looks. How do I get the array from toprefs when there is no name for the different arrays? Below is the JSON:

   -{
      path: "/a_vc/2013/03/revenue-traction-doesnt-mean-product-market-fit.html"
     -stats: {
          direct: 25
          visits: 52
          subscr: 0
          -platform: {
             m: 0
             d: 52
          }
          -toprefs: [
             -{
                visitors: 9
                domain: "t.co"
              }
             -{
                visitors: 2
                domain: "facebook.com"
             }
             -{
                visitors: 2
                domain: "linkedin.com"
             }
             -{
                visitors: 1
                domain: "google.com"
             }
             -{
                visitors: 1
                domain: "avc.blogs.com"
             }
          ]
          search: 0
          crowd: 0

       }
      title: "A VC: Revenue Traction Doesn't Mean Product Market Fit"
  }


   (function() {
         var chartBeat = "http://api.com";
         $.getJSON( chartBeat, {
         format: "json"
   })

   .done(function( data ) {
         $.each( data.pages, function( i, page ) {
             var pageNumber = i + 1;

             var stats = [page.stats];

             $('#pages').append('<li>Page ' + pageNumber + ': ' + page.title + '</li>');

                $.each( stats, function( s, stat ) {
        var toprefs = [stat.toprefs];

        $.each( toprefs, function( t, topref ) {
            var refs = [toprefs];

            $.each( refs, function( r, ref ) {
                $('#page-details').append('<li>' + ref.domain + '</li>');
            });
        });
    });

    });

Please help, I am very stuck, but soooo close.

Amar
  • 11,930
  • 5
  • 50
  • 73
Jamie
  • 1,909
  • 3
  • 22
  • 47
  • 1
    What's up with the hyphens? And that's not JSON, looks like a javascript object though (if you remove the hyphens) ? – adeneo Mar 25 '13 at 21:09
  • that is just how its organized on the site.. there is no actual hypens in the json response.. – Jamie Mar 25 '13 at 21:10
  • There should be comma's ? – adeneo Mar 25 '13 at 21:11
  • @adeneo the actual json response looks normal.. im trying to get the data though... its not really about the json response.. you can view it here if you would like http://api.chartbeat.com/live/toppages/v3/?apikey=317a25eccba186e0f6b558f45214c0e7&host=avc.com – Jamie Mar 25 '13 at 21:13
  • You'd access each aray instance like `object.toprefs[3]` to get the fourth instance etc. – adeneo Mar 25 '13 at 21:15
  • how would i get all the values... thank you SO MUCH @FelixKling – Jamie Mar 25 '13 at 21:17

0 Answers0