在Javascript(NodeJS)中访问JSON内容

时间:2017-11-12 15:14:29

标签: javascript json xml2js

使用nodejs需要从json获取字符串值。

json看起来像这样:

`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] ] } ]`

如何访问dc:title(或任何其他)值?

我正在尝试不同的方式,例如console.log(result["DIDL-Lite"]["item"]["dc:title"]);,但我根本无法让它发挥作用......

任何提示?谢谢你!

0 个答案:

没有答案