Hi everyone,
I’m facing an issue for 3 hours when trying to properly extract all values from a nested JSON object.
My automation goal:
• I’m scraping a website to collect data in JSON format.
• One of the key pieces of data is popularTimesHistogram , which contains occupancy rates (occupancyPercent) per hour (hour) for each day of the week (Su, Mo, Tu, etc.) .
Simplified JSON example:
"popularTimesHistogram": {
"Su": [
{ "hour": 4, "occupancyPercent": 10 },
{ "hour": 5, "occupancyPercent": 7 },
{ "hour": 6, "occupancyPercent": 8 }
],
"Mo": [
{ "hour": 4, "occupancyPercent": 17 },
{ "hour": 5, "occupancyPercent": 27 }
]
}
Goal: Extract all values and display them in this format:
Su: 4h: 10% | 5h: 7% | 6h: 8%
Mo: 4h: 17% | 5h: 27%
What I’ve tried so far:
Simple request to retrieve each value
{{3.popularTimesHistogram.Su[].hour}}{{3.popularTimesHistogram.Su[].occupancyPercent}}
Issue: It only returns the last value of the list.
Using map() to loop through all values
{{join(map(3.popularTimesHistogram.Su; "hour"; "occupancyPercent"); " | ")}}
Issue: It only returns the hours, but not the occupancy rates.
Trying to concatenate values correctly
{{join(map(3.popularTimesHistogram.Su; "hour"); "h : ") & " - " & join(map(3.popularTimesHistogram.Su; "occupancyPercent"); "% | ")}}
Issue: It only returns the occupancy rates, but the hours disappear.
Using modules like Array Aggregator, ParseJSON, and converting to CSV , ask to chatgpt , ask to make ai
Issue: Some methods remove data or don’t allow me to reconstruct the structure.
My final goal:
I want to send this data to ChatGPT , so it can analyze multiple gyms based on their occupancy rates and recommend the best gym depending on the current time .
Since each gym’s data is sent as separate bundles, I’ll likely store the results in Google Sheets first before sending them all together to ChatGPT.
My question:
How can I properly extract all values from popularTimesHistogram (days, hours, and occupancy percentages) in a single request?
Thanks in advance for your help!