So I have this JSON:
{
"success": {
"total": 1
},
"contents": {
"quotes": [
{
"quote": "When you win, say nothing. When you lose, say less.",
"length": "51",
"author": "Paul Brown",
"tags": {
"0": "inspire",
"1": "losing",
"2": "running",
"4": "winning"
},
"category": "inspire",
"language": "en",
"date": "2022-03-05",
"permalink": "https://theysaidso.com/quote/paul-brown-when-you-win-say-nothing-when-you-lose-say-less",
"id": "3dlKxoNAOZsB__Nb61H95weF",
"background": "https://theysaidso.com/img/qod/qod-inspire.jpg",
"title": "Inspiring Quote of the day"
}
]
},
"baseurl": "https://theysaidso.com",
"copyright": {
"year": 2024,
"url": "https://theysaidso.com"
}
}
I am trying to grab the text in the author and quote fields into two respective variables. I've already assigned the variable JSON to the json contents. What I have right now is the following below that doesn't work.
QUOTE = JSON.contents.quotes[0].quote;
AUTHOR = JSON.contents.quotes[0].author;
What am I doing wrong? And what would be the correct approach?
JSONto something else, asJSONis a standard built in JS object.