-
Notifications
You must be signed in to change notification settings - Fork 1
/
sample.js
21 lines (16 loc) · 16 KB
/
sample.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
var sample = '{"response":{"meta":{"hits":1339,"time":19,"offset":0},"docs":[{"web_url":"http:\/\/krugman.blogs.nytimes.com\/2016\/06\/12\/notes-on-brexit\/","snippet":"Remain, but with feelings of despair.","lead_paragraph":null,"abstract":"Remain, but with feelings of despair.","print_page":null,"blog":[],"source":"The New York Times","multimedia":[],"headline":{"main":"Notes on Brexit","kicker":"Paul Krugman"},"keywords":[],"pub_date":"2016-06-12T13:13:38Z","document_type":"blogpost","news_desk":"OpEd","section_name":"Opinion","subsection_name":null,"byline":{"person":[{"organization":"","role":"reported","firstname":"Paul","rank":1,"lastname":"KRUGMAN"}],"original":"By PAUL KRUGMAN"},"type_of_material":"Blog","_id":"575d98bc38f0d846c1eadaeb","word_count":"710","slideshow_credits":null},{"web_url":"http:\/\/www.nytimes.com\/2016\/06\/17\/opinion\/fear-loathing-and-brexit.html","snippet":"Britons have a choice between bad and worse.","lead_paragraph":"Britons have a choice between bad and worse.","abstract":"Paul Krugman Op-Ed column acknowledges serious drawbacks for Great Britain whether it leaves European Union or stays in; advises remaining, as exit would lead to significant financial troubles for Britain; notes major mistakes made by union, including adoption of Euro, and lack of accountability.","print_page":"29","blog":[],"source":"The New York Times","multimedia":[{"width":190,"url":"images\/2014\/11\/12\/opinion\/krugman-circular\/krugman-circular-thumbWide-v5.jpg","height":126,"subtype":"wide","legacy":{"wide":"images\/2014\/11\/12\/opinion\/krugman-circular\/krugman-circular-thumbWide-v5.jpg","wideheight":"126","widewidth":"190"},"type":"image"},{"width":600,"url":"images\/2014\/11\/12\/opinion\/krugman-circular\/krugman-circular-articleLarge-v2.jpg","height":591,"subtype":"xlarge","legacy":{"xlargewidth":"600","xlarge":"images\/2014\/11\/12\/opinion\/krugman-circular\/krugman-circular-articleLarge-v2.jpg","xlargeheight":"591"},"type":"image"},{"width":75,"url":"images\/2014\/11\/12\/opinion\/krugman-circular\/krugman-circular-thumbStandard-v5.jpg","height":75,"subtype":"thumbnail","legacy":{"thumbnailheight":"75","thumbnail":"images\/2014\/11\/12\/opinion\/krugman-circular\/krugman-circular-thumbStandard-v5.jpg","thumbnailwidth":"75"},"type":"image"}],"headline":{"main":"Fear, Loathing and Brexit","content_kicker":"Op-Ed Columnist","kicker":"Op-Ed Columnist","print_headline":"Fear, Loathing and Brexit"},"keywords":[{"rank":"1","is_major":"Y","name":"organizations","value":"European Union"},{"rank":"2","is_major":"Y","name":"glocations","value":"Great Britain"},{"rank":"3","is_major":"N","name":"subject","value":"International Trade and World Market"},{"rank":"4","is_major":"N","name":"subject","value":"Referendums"}],"pub_date":"2016-06-17T00:00:00Z","document_type":"article","news_desk":"OpEd","section_name":"Opinion","subsection_name":null,"byline":{"person":[{"organization":"","role":"reported","firstname":"Paul","rank":1,"lastname":"KRUGMAN"}],"original":"By PAUL KRUGMAN"},"type_of_material":"Op-Ed","_id":"5763a4e338f0d83da36e064d","word_count":"824","slideshow_credits":null},{"web_url":"http:\/\/www.nytimes.com\/2016\/06\/19\/world\/europe\/regardless-of-brexit-vote-experts-say-eu-must-rethink-status-quo.html","snippet":"Tribulations for the euro, a debt standoff with Greece and a flawed approach to migration all inflamed the angry nationalism spreading across the Continent and Britain.","lead_paragraph":"Tribulations for the euro, a debt standoff with Greece and a flawed approach to migration all inflamed the angry nationalism spreading across the Continent and Britain.","abstract":null,"print_page":"1","blog":[],"source":"The New York Times","multimedia":[{"width":190,"url":"images\/2016\/06\/19\/world\/19EUROPE\/19EUROPE-thumbWide.jpg","height":126,"subtype":"wide","legacy":{"wide":"images\/2016\/06\/19\/world\/19EUROPE\/19EUROPE-thumbWide.jpg","wideheight":"126","widewidth":"190"},"type":"image"},{"width":600,"url":"images\/2016\/06\/19\/world\/19EUROPE\/19EUROPE-articleLarge.jpg","height":666,"subtype":"xlarge","legacy":{"xlargewidth":"600","xlarge":"images\/2016\/06\/19\/world\/19EUROPE\/19EUROPE-articleLarge.jpg","xlargeheight":"666"},"type":"image"},{"width":75,"url":"images\/2016\/06\/19\/world\/19EUROPE\/19EUROPE-thumbStandard.jpg","height":75,"subtype":"thumbnail","legacy":{"thumbnailheight":"75","thumbnail":"images\/2016\/06\/19\/world\/19EUROPE\/19EUROPE-thumbStandard.jpg","thumbnailwidth":"75"},"type":"image"}],"headline":{"main":"Regardless of \u2018Brexit\u2019 Vote, Experts Say, E.U. Must Rethink Status Quo","print_headline":"\u2018Brexit\u2019 Vote Reflects How Diversity Adds to E.U. Pain"},"keywords":[{"rank":"1","is_major":"N","name":"subject","value":"European Sovereign Debt Crisis (2010- )"},{"rank":"2","is_major":"N","name":"subject","value":"Refugees and Displaced Persons"},{"rank":"3","is_major":"N","name":"subject","value":"Euro (Currency)"},{"rank":"4","is_major":"N","name":"organizations","value":"European Union"},{"rank":"5","is_major":"N","name":"organizations","value":"Eurozone"},{"rank":"6","is_major":"N","name":"glocations","value":"Europe"},{"rank":"7","is_major":"N","name":"glocations","value":"Great Britain"}],"pub_date":"2016-06-19T00:00:00Z","document_type":"article","news_desk":"Foreign","section_name":"World","subsection_name":"Europe","byline":{"person":[{"organization":"","role":"reported","firstname":"Jim","rank":1,"lastname":"YARDLEY"}],"original":"By JIM YARDLEY"},"type_of_material":"News","_id":"57658c0838f0d86d6f5e7d67","word_count":"1532","slideshow_credits":null},{"web_url":"http:\/\/www.nytimes.com\/video\/world\/europe\/100000004444271\/khan-and-cameron-try-to-stop-a-brexit.html","snippet":"Mayor Sadiq Khan of London, of the Labour Party, and David Cameron, the Conservative prime minister, campaigned together against Britain leaving the European Union.","lead_paragraph":"Mayor Sadiq Khan of London, of the Labour Party, and David Cameron, the Conservative prime minister, campaigned together against Britain leaving the European Union.","abstract":null,"print_page":null,"blog":[],"source":"Reuters","multimedia":[{"width":190,"url":"images\/2016\/05\/31\/world\/31BREXIT-WEB\/31BREXIT-WEB-thumbWide.jpg","height":126,"subtype":"wide","legacy":{"wide":"images\/2016\/05\/31\/world\/31BREXIT-WEB\/31BREXIT-WEB-thumbWide.jpg","wideheight":"126","widewidth":"190"},"type":"image"},{"width":600,"url":"images\/2016\/05\/31\/world\/31BREXIT-WEB\/31BREXIT-WEB-articleLarge.jpg","height":412,"subtype":"xlarge","legacy":{"xlargewidth":"600","xlarge":"images\/2016\/05\/31\/world\/31BREXIT-WEB\/31BREXIT-WEB-articleLarge.jpg","xlargeheight":"412"},"type":"image"},{"width":75,"url":"images\/2016\/05\/31\/world\/31BREXIT-WEB\/31BREXIT-WEB-thumbStandard.jpg","height":75,"subtype":"thumbnail","legacy":{"thumbnailheight":"75","thumbnail":"images\/2016\/05\/31\/world\/31BREXIT-WEB\/31BREXIT-WEB-thumbStandard.jpg","thumbnailwidth":"75"},"type":"image"}],"headline":{"main":"Joining Forces to Prevent a \u2018Brexit\u2019"},"keywords":[{"rank":"1","is_major":"N","name":"persons","value":"Cameron, David"},{"rank":"2","is_major":"N","name":"persons","value":"Khan, Sadiq"},{"rank":"3","is_major":"N","name":"organizations","value":"European Union"}],"pub_date":"2016-05-30T18:38:09Z","document_type":"multimedia","news_desk":"World \/ Europe","section_name":"World","subsection_name":"Europe","byline":{"person":[],"original":"By REUTERS","organization":"REUTERS"},"type_of_material":"Video","_id":"574cc0fd38f0d826276781c8","word_count":"24","slideshow_credits":null},{"web_url":"http:\/\/www.nytimes.com\/2016\/06\/06\/opinion\/contemplating-the-reality-of-brexit.html","snippet":"A reader writes that few people in Britain are aware of what the European Union actually does, and few care very much about it.","lead_paragraph":"A reader writes that few people in Britain are aware of what the European Union actually does, and few care very much about it.","abstract":null,"print_page":null,"blog":[],"source":"The New York Times","multimedia":[],"headline":{"main":"Contemplating the Reality of Brexit","content_kicker":"Letter","kicker":"Letter"},"keywords":[{"rank":"1","is_major":"N","name":"organizations","value":"European Union"},{"rank":"2","is_major":"N","name":"glocations","value":"Great Britain"}],"pub_date":"2016-06-06T00:00:00Z","document_type":"article","news_desk":"OpEd","section_name":"Opinion","subsection_name":null,"byline":[],"type_of_material":"Letter","_id":"57558bba38f0d82b6575fefe","word_count":"175","slideshow_credits":null},{"web_url":"http:\/\/www.nytimes.com\/2016\/05\/29\/business\/brexit-and-britains-economy.html","snippet":"Readers respond to \u201cThe Feel-Good Vote That Could Sink Britain\u2019s Economy\u201d (May 22).","lead_paragraph":"Readers respond to \u201cThe Feel-Good Vote That Could Sink Britain\u2019s Economy\u201d (May 22).","abstract":null,"print_page":"5","blog":[],"source":"The New York Times","multimedia":[],"headline":{"main":"Brexit and Britain\u2019s Economy","content_kicker":"Letters","kicker":"Letters","print_headline":"Comments"},"keywords":[{"rank":"1","is_major":"N","name":"organizations","value":"European Union"},{"rank":"2","is_major":"N","name":"glocations","value":"Great Britain"},{"rank":"3","is_major":"N","name":"subject","value":"Economic Conditions and Trends"}],"pub_date":"2016-05-29T00:00:00Z","document_type":"article","news_desk":"SundayBusiness","section_name":"Business Day","subsection_name":null,"byline":[],"type_of_material":"News","_id":"5749d6f238f0d8190d624113","word_count":"235","slideshow_credits":null},{"web_url":"http:\/\/krugman.blogs.nytimes.com\/2016\/06\/17\/friday-night-music-a-song-for-brexit\/","snippet":"In spite of all temptations.","lead_paragraph":null,"abstract":"In spite of all temptations.","print_page":null,"blog":[],"source":"The New York Times","multimedia":[],"headline":{"main":"Friday Night Music: A Song for Brexit","kicker":"Paul Krugman"},"keywords":[],"pub_date":"2016-06-17T19:52:21Z","document_type":"blogpost","news_desk":"OpEd","section_name":"Opinion","subsection_name":null,"byline":{"person":[{"organization":"","role":"reported","firstname":"Paul","rank":1,"lastname":"KRUGMAN"}],"original":"By PAUL KRUGMAN"},"type_of_material":"Blog","_id":"57648da738f0d8589e8e2189","word_count":"11","slideshow_credits":null},{"web_url":"http:\/\/www.nytimes.com\/2016\/05\/18\/world\/europe\/brexit-vote-youth.html","snippet":"Young Britons seem to favor staying in the bloc. They have never known a divided Europe without visa-free travel, cheap flights and job mobility.","lead_paragraph":"Young Britons seem to favor staying in the bloc. They have never known a divided Europe without visa-free travel, cheap flights and job mobility.","abstract":null,"print_page":null,"blog":[],"source":"The New York Times","multimedia":[{"width":190,"url":"images\/2016\/05\/18\/world\/18LETTER-web1\/18LETTER-web1-thumbWide.jpg","height":126,"subtype":"wide","legacy":{"wide":"images\/2016\/05\/18\/world\/18LETTER-web1\/18LETTER-web1-thumbWide.jpg","wideheight":"126","widewidth":"190"},"type":"image"},{"width":600,"url":"images\/2016\/05\/18\/world\/18LETTER-web1\/18LETTER-web1-articleLarge.jpg","height":400,"subtype":"xlarge","legacy":{"xlargewidth":"600","xlarge":"images\/2016\/05\/18\/world\/18LETTER-web1\/18LETTER-web1-articleLarge.jpg","xlargeheight":"400"},"type":"image"},{"width":75,"url":"images\/2016\/05\/18\/world\/18LETTER-web1\/18LETTER-web1-thumbStandard.jpg","height":75,"subtype":"thumbnail","legacy":{"thumbnailheight":"75","thumbnail":"images\/2016\/05\/18\/world\/18LETTER-web1\/18LETTER-web1-thumbStandard.jpg","thumbnailwidth":"75"},"type":"image"}],"headline":{"main":"Britain\u2019s Youth Versus \u2018Brexit\u2019","content_kicker":"Letter from Europe","kicker":"Letter from Europe"},"keywords":[{"rank":"2","is_major":"N","name":"glocations","value":"Great Britain"},{"rank":"3","is_major":"N","name":"organizations","value":"European Union"},{"rank":"4","is_major":"N","name":"subject","value":"Immigration and Emigration"}],"pub_date":"2016-05-18T00:00:00Z","document_type":"article","news_desk":"Foreign","section_name":"World","subsection_name":"Europe","byline":{"person":[{"organization":"","role":"reported","firstname":"Alison","rank":1,"lastname":"SMALE"}],"original":"By ALISON SMALE"},"type_of_material":"News","_id":"573b460f38f0d86c87c2c915","word_count":"726","slideshow_credits":null},{"web_url":"http:\/\/www.nytimes.com\/2016\/06\/17\/opinion\/jo-cox-brexit-and-the-politics-of-hate.html","snippet":"Is a member of Parliament\u2019s killing a sign of how toxic British politics have become?","lead_paragraph":"Is a member of Parliament\u2019s killing a sign of how toxic British politics have become?","abstract":null,"print_page":null,"blog":[],"source":"The New York Times","multimedia":[{"width":190,"url":"images\/2016\/06\/18\/opinion\/17trillingWeb\/18trillingWeb-thumbWide.jpg","height":126,"subtype":"wide","legacy":{"wide":"images\/2016\/06\/18\/opinion\/17trillingWeb\/18trillingWeb-thumbWide.jpg","wideheight":"126","widewidth":"190"},"type":"image"},{"width":600,"url":"images\/2016\/06\/18\/opinion\/17trillingWeb\/18trillingWeb-articleLarge.jpg","height":450,"subtype":"xlarge","legacy":{"xlargewidth":"600","xlarge":"images\/2016\/06\/18\/opinion\/17trillingWeb\/18trillingWeb-articleLarge.jpg","xlargeheight":"450"},"type":"image"},{"width":75,"url":"images\/2016\/06\/18\/opinion\/17trillingWeb\/18trillingWeb-thumbStandard.jpg","height":75,"subtype":"thumbnail","legacy":{"thumbnailheight":"75","thumbnail":"images\/2016\/06\/18\/opinion\/17trillingWeb\/18trillingWeb-thumbStandard.jpg","thumbnailwidth":"75"},"type":"image"}],"headline":{"main":"Jo Cox, Brexit and the Politics of Hate","content_kicker":"Op-Ed Contributor","kicker":"Op-Ed Contributor","print_headline":"Jo Cox, Brexit and the Politics of Hate"},"keywords":[{"rank":"1","is_major":"N","name":"persons","value":"Cox, Jo (1974-2016)"},{"rank":"2","is_major":"N","name":"subject","value":"Murders, Attempted Murders and Homicides"},{"rank":"3","is_major":"N","name":"subject","value":"Immigration and Emigration"},{"rank":"4","is_major":"N","name":"glocations","value":"Great Britain"},{"rank":"5","is_major":"N","name":"subject","value":"Fringe Groups and Movements"}],"pub_date":"2016-06-17T00:00:00Z","document_type":"article","news_desk":"OpEd","section_name":"Opinion","subsection_name":null,"byline":{"person":[{"organization":"","role":"reported","firstname":"Daniel","rank":1,"lastname":"TRILLING"}],"original":"By DANIEL TRILLING"},"type_of_material":"Op-Ed","_id":"576467d038f0d8589e8e212c","word_count":"1076","slideshow_credits":null},{"web_url":"http:\/\/www.nytimes.com\/reuters\/2016\/05\/31\/world\/europe\/31reuters-britain-eu-roadmap.html","snippet":"Dawn, Friday, June 24. The votes are in. The British have spoken in their EU membership referendum and they want out. It is a scenario European leaders are now planning for in earnest while praying it never happens.","lead_paragraph":"Dawn, Friday, June 24. The votes are in. The British have spoken in their EU membership referendum and they want out. It is a scenario European leaders are now planning for in earnest while praying it never happens.","abstract":null,"print_page":null,"blog":[],"source":"Reuters","multimedia":[],"headline":{"main":"After Brexit-Roadmap for a Leap in the Dark","print_headline":"After Brexit-Roadmap for a Leap in the Dark"},"keywords":[],"pub_date":"2016-05-31T13:32:34Z","document_type":"article","news_desk":"None","section_name":"World","subsection_name":"Europe","byline":{"person":[],"original":"By REUTERS","organization":"REUTERS"},"type_of_material":"News","_id":"574dcafb38f0d8334c662fdd","word_count":"1562","slideshow_credits":null}]},"status":"OK","copyright":"Copyright (c) 2013 The New York Times Company. All Rights Reserved."}'
function parseNYTJson(jsonObj) {
var retArr = [];
var length = 3;
for (var i = 0; i < length; i++) {
var item = {}
item.headline
retArr.push({
headline: jsonObj.response.docs[i].headline.main,
summary: jsonObj.response.docs[i].abstract || jsonObj.response.docs[i].lead_paragraph,
url: jsonObj.response.docs[i].web_url
});
}
return retArr;
}
parseNYTJson(JSON.parse(sample));