0

im working with nodejs an need to get a string value from a json.

The json looks like this:

`result["DIDL-Lite"]["item"] = [ { '$': { id: '0/Spotify/Track', parentID: '0/Spotify', restricted: '0' },
'upnp:class': [ 'object.item.audioItem.musicTrack' ],
'raumfeld:section': [ 'Spotify' ],
'dc:title': [ 'Californication' ],
'upnp:artist': [ 'Red Hot Chili Peppers' ],
'upnp:album': [ 'Californication (Deluxe Version)' ],
'upnp:albumArtURI': [ [Object] ] } ]`

how can i access the dc:title (or any other) value?

I'm trying different ways, e.g. console.log(result["DIDL-Lite"]["item"]["dc:title"]);, but I simply can't get it work...

Any tips? Thank you in adavance!!

dhilt
  • 18,707
  • 8
  • 70
  • 85
  • You have an array; you need to get one of its elements. – SLaks Nov 12 '17 at 15:17
  • Get the 0 element before: `result["DIDL-Lite"]["item"][0]["dc:title"]` – dhilt Nov 12 '17 at 15:18
  • Thank you! another question: the object in albumArtURI looks like `{ _: 'http://o.scdn.co/320/83ad9372450f69b4d31117d0d1467cd3df703c13', '$': { 'dlna:profileID': 'JPEG_TN' } }` whats the trick here to access the url? – Doenermann Nov 12 '17 at 15:49
  • got it myself. same story: `result["DIDL-Lite"]["item"][0]["upnp:albumArtURI"][0]["_"]`. – Doenermann Nov 12 '17 at 16:19

0 Answers0