Access to a JSON variable predefined using a hash (#)

Last.fm seems to put characters #in front of some variable names for the JSON API. See an example answer here . As soon as I try to access #textusing JavaScript, I get an invalid character error in the console. Quick fixes or reasons for this hash?

+5
source share
1 answer

jQuery is used only to retrieve data. Data is #textaccessed through direct JavaScript syntax, something likedata.recenttracks.track.artist["#text"]

You cannot do this artist.#textbecause it #is an invalid character for the first character that will be used to access a member of the object. Use square brackets instead.

+6
source

All Articles