If you go to the site http://json.parser.online.fr it will let you paste in data and check to see if it's valid JSON or not. Yours is not.
As others have said, strings need to be enclosed in double quotes, not single quotes, and the "=" is not valid.
It would be quite easy to write code that would replace all occurrences of '
with "
. The song =
bit is less clear. The correct format for JSON would be:
{
"song": {
"artist":"Tom Waits",
"song":"New Coat Of Paint",
"lyrics":"Let"s put a new coat of paint on this lonesome old town
Set "em up, we"ll be knockin" em [...]",
"url":"http://lyrics.wikia.com/Tom_Waits:New_Coat_Of_Paint"
}
}
Or you could get rid of the outer dictionary entirely:
{
"artist":"Tom Waits",
"song":"New Coat Of Paint",
"lyrics":"Let"s put a new coat of paint on this lonesome old town
Set "em up, we"ll be knockin" em [...]",
"url":"http://lyrics.wikia.com/Tom_Waits:New_Coat_Of_Paint"
}
You need to look at your data and figure out what's wrong with it in the general case that makes it not legal JSON.
EDIT:
After further digging, it seems that the URLs you're using are returning JavaScript, not JSON. Try an URL like this instead:
http://lyrics.wikia.com/wikia.php?controller=LyricsApi&method=getSong&artist=Tom%20Waits&song=new%20coat%20of%20paint
That should give you the lyrics of the Tom Waits song New Coat of Paint in well-formed JSON.
This Github page gives info on the search parameters you can use to query that site and get lyrics:
https://github.com/Wikia/app/blob/dev/extensions/wikia/LyricsApi/LyricsApiController.class.php#L10-L15
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…