0
일부 실시간 스트리밍 JSON 데이터를 구문 분석하고 이벤트에 특정 태그가 있는지 확인하려고합니다. 그 다음 I이 어떤 이유 등자바 스크립트 함수에서 JSON 객체 반환
출력값 데이터를 사용할 것이다 없으면 , upcoming_event
는 findPublicEvent
함수의 리턴 값 이벤트 객체 (할당되는 것은 아니다.
을 console.log 잘 작동 -하지만이 작동하지 않습니다, 리턴 :./
// get our NLC data from livestream.
// -> note: need the '?callback=?' to convert to JSONP for cross-domain usage
var $uri = 'http://api.new.livestream.com/accounts/newlifechurchtv/?callback=?';
$.getJSON($uri, function(data) {
parseNLCData(data);
});
parseNLCData = function(nlc_data){
// set our variable to the return first event
// nlc_data.upcoming_events.data is a json array of events
window.upcoming_event = findPublicEvent(nlc_data.upcoming_events.data);
}
// should return single public event
function findPublicEvent (all_events) {
// if we have events
if (all_events) {
// loop through events to find public event
$.each(all_events, function(index,value){
// get all the tags, remove whitespace, and put into array
var $tags = value.tags.replace(/ /g, '').toLowerCase().split(',');
// check for privacy.
var $privacy = $.inArray('private', $tags);
if ($privacy === -1) {
// if the event isn't private -> return it!
console.log(value);
return value;
}
});
// otherwise .... ->
} else {
// we don't have events, sooo, no dice.
return false;
}
};
에서 도와 주셔서 대단히 감사합니다 @ 퀸틴! 매력처럼 작동합니다 : D – watts