1

我找到了问题..我仍然有问题..这是 JSON 的外观。当没有不同数组的名称时,如何从 toprefs 获取数组?下面是 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>');
            });
        });
    });

    });

请帮忙,我很卡住,但太接近了。

4

0 回答 0