2017-02-26 5 views
0

JSを依存します。通知長はReadFlag

これは私のJSONへのリンクが https://api.myjson.com/bins/navph

+0

あなたがやりたい正確に何を明確にしてくださいだろうか? **任意の**または** **アイテムに_ReadFlag_ 0が1つしかないときの長さを望みますか? – caisah

+0

私はReadFlag 0 – poojay

答えて

0

あなたはこのようなものを使用することができます:

function getJSON() { 
    $.ajax({ 
     url: "https://api.myjson.com/bins/navph", 
     type: "GET", 
     crossDomain: true, 
     success: function(res) { 
      var lens = res.filter(function(item) { 
       // filter by source 
       return item.Source === 'CIRIS'; 
      }).map(function(item) { 
       // get only Notifications 
       return item.Notifications; 
      }).map(function(notification){ 
       // get lengths of notifications which have at least 1 RedFlag not 0 
       return (notification.filter(function(item){ 
        return item.RedFlag !== 0; 
       }).length) 
      }) 
      console.log(lens[0]); 
     } 
    }) 
} 

getJSON(); 
+0

を持っているアイテムの長さが必要です。これを試しました。 readflagが0か1かどうかにかかわらず、私はまだ全長の長さを返す – poojay