Hey there! Thanks for taking the time to check out my question. I'm diving into JavaScript and I've hit a roadblock trying to solve this particular problem:
I'm looking to extract the value of a property nested within a JSON object under a dynamically changing property name. Here's the JSON object:
{
"batchcomplete": "",
"query": {
"normalized": [
{
"from": "Theodore_Rubin",
"to": "Theodore Rubin"
}
],
"pages": {
"11820415": {
"pageid": 11820415,
"ns": 0,
"title": "Theodore Rubin",
"contentmodel": "wikitext",
"pagelanguage": "en",
"pagelanguagehtmlcode": "en",
"pagelanguagedir": "ltr",
"touched": "2016-02-12T17:34:52Z",
"lastrevid": 138813300,
"length": 34,
"redirect": "",
"new": "",
"fullurl": "https://en.wikipedia.org/wiki/Theodore_Rubin",
"editurl": "https://en.wikipedia.org/w/index.php?title=Theodore_Rubin&action=edit",
"canonicalurl": "https://en.wikipedia.org/wiki/Theodore_Rubin"
}
}
}
}
My goal is to capture the value of the fullurl
property in a variable. While I know that using bracket and dot notation like query.pages["2123909"].fullurl
can access it, the challenge is that the property name changes with each JSON request.
How could I retrieve the value of the fullurl
property without knowing its parent property name?
Your assistance is greatly appreciated!