Saturday 10 June 2017

Get values from Objects

I am writing code to get the XML from a site and parse it.

I want to get all titles from the parsed json. How can I do that?

How can I get the values of the Objects from a key (parsed Json) using NodeJS?

parsed JSON:

[ { title: [ 'NOS Nieuws' ],
    link: [ 'http://nos.nl' ],
    description: [ 'NOS Nieuws' ],
    language: [ 'nl' ],
    copyright: [ 'Copyright NOS' ],
    pubDate: [ 'Sat, 10 Jun 2017 20:50:35 +0200' ],
    webMaster: [ 'podcast@nos.nl (NOS Podcast Beheer)' ],
    'atom10:link': [ [Object], [Object] ],
    'feedburner:info': [ [Object] ],
    item: 
     [ [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object] ] } ]

JS:

  var test = JSON.stringify(data, null, 2);

  var obj = JSON.parse(test);
 console.log(obj.rss.channel);

Thanks.



via Teun

No comments:

Post a Comment