5

Last.fm seems to put # symbols in front of some of their variable names for it's JSON API. Have a look at a sample response here. As soon as I try and access #text with JavaScript I get an invalid symbol error in the console. Any quick fixes or reasons for this hash?

Community
  • 1
  • 1
greenimpala
  • 3,777
  • 3
  • 31
  • 39

1 Answers1

6

jQuery is only used to retrieve the data. Accessing the #text data is done through straight JavaScript syntax, something like data.recenttracks.track.artist["#text"]

You can't do artist.#text , because # is an invalid first character symbol to be used for accessing an object member. Use the square brackets instead.

Luca Matteis
  • 29,161
  • 19
  • 114
  • 169