I am trying to read JSON response data from a Restful API that contains a space in the path. I am trying to accomplish this in JavaScript, but can't seem to get the data to display.
Below is the JSON I am working with:
"fields": {
"census": {...},
"acs": {
"meta": {
"source": "American Community Survey from the US Census Bureau",
"survey_years": "2014-2018",
"survey_duration_years": "5"
},
"demographics": {
"Median age": {
"meta": {
"table_id": "B01002",
"universe": "Total population"
},
"Total": {
"value": 32.8,
"margin_of_error": 0.6
As you can see, the Median Age field has a space. The actual data I am trying to obtain is the Median age total value.
Below is my JSON path that isn't working:
let ageDems = await response.data.results[0].fields.demographics.$["Median age"].Total.value;
I have also tried to use ['Median Age'], ["Median Age"] and Median+Age and none of those worked either. Can anyone please assist me in writing the correct path to obtain the data I need?
acspart.const ageDems = response.data.results[0].fields.demographics["Median age"].Total.value;,console.log(ageDems )