Support Center

Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

JSON Format

Keith Francis Mar 15, 2019 03:05PM GMT

I'm trying to decode the 5 day / 3 hour JSON file using Swift 4.2 for an IOS app (for my own use - I'm a hobbyist). My understanding of the JSON file I'm receiving is that it has a number of arrays of dictionaries representing the forecast info in it (the number of arrays = cnt) and also a few other arrays. My question is this - aren't arrays supposed t be enclosed with [] brackets? The file I'm receiving seems to enclose the arrays with () braces.

Am I misunderstanding something?

Thanks,
Keith

Up 0 rated Down
Pavel Zuykov Mar 17, 2019 07:23PM GMT OpenWeatherMap Agent

Hello,

Thank you for request. Please check example below from live API (collected using Postman)

As you can see, arrays enclosed with [] brackets.

{
“cod”: “200”,
“message”: 0.0051,
“cnt”: 2,
“list”: [
{
“dt”: 1552856400,
“main”: {
“temp”: 273.5,
“temp_min”: 270.681,
“temp_max”: 273.5,
“pressure”: 1016.93,
“sea_level”: 1016.93,
“grnd_level”: 996.57,
“humidity”: 91,
“temp_kf”: 2.81
},
“weather”: [
{
“id”: 800,
“main”: “Clear”,
“description”: “clear sky”,
“icon”: “01n”
}
],
“clouds”: {
“all”: 32
},
“wind”: {
“speed”: 3.22,
“deg”: 163.5
},
“snow”: {
“3h”: 0.018
},
“sys”: {
“pod”: “n”
},
“dt_txt”: “2019-03-17 21:00:00”
},
{
“dt”: 1552867200,
“main”: {
“temp”: 273.64,
“temp_min”: 271.526,
“temp_max”: 273.64,
“pressure”: 1018.18,
“sea_level”: 1018.18,
“grnd_level”: 997.77,
“humidity”: 91,
“temp_kf”: 2.11
},
“weather”: [
{
“id”: 600,
“main”: “Snow”,
“description”: “light snow”,
“icon”: “13n”
}
],
“clouds”: {
“all”: 80
},
“wind”: {
“speed”: 3.24,
“deg”: 173.5
},
“snow”: {
“3h”: 0.04475
},
“sys”: {
“pod”: “n”
},
“dt_txt”: “2019-03-18 00:00:00”
}
],
“city”: {
“id”: 524901,
“name”: “Moscow”,
“coord”: {
“lat”: 55.7507,
“lon”: 37.6177
},
“country”: “RU”,
“population”: 1000000
}
}

Up 0 rated Down
Keith Francis Mar 23, 2019 01:29AM GMT
Hello Pavel
I don't agree with your answer. Here is a partial dump of the JSON from the 5 day / 3 hour forecast that I got a few minutes ago. Not a single set of []'s in it. Are you suggesting that I have to replace () with []?
City = Cupertino
{
city = {
coord = {
lat = "43.4254";
lon = "-80.5112";
};
country = CA;
id = 5992996;
name = Kitchener;
};
cnt = 39;
cod = 200;
list = (
{
clouds = {
all = 56;
};
dt = 1553310000;
"dt_txt" = "2019-03-23 03:00:00";
main = {
"grnd_level" = "981.55";
humidity = 67;
pressure = 1016;
"sea_level" = 1016;
temp = "-3.45";
"temp_kf" = "0.05";
"temp_max" = "-3.45";
"temp_min" = "-3.51";
};
snow = {
3h = "0.002";
};
sys = {
pod = n;
};
weather = (
{
description = "clear sky";
icon = 01n;
id = 800;
main = Clear;
}
);
wind = {
deg = "337.004";
speed = "9.27";
};
},
{
clouds = {
all = 0;
};
dt = 1553320800;
"dt_txt" = "2019-03-23 06:00:00";
main = {
"grnd_level" = "982.8";
humidity = 60;
pressure = "1017.41";
"sea_level" = "1017.41";
temp = "-5.04";
"temp_kf" = "0.04";
"temp_max" = "-5.04";
"temp_min" = "-5.08";
};
snow = {
};
sys = {
pod = n;
};
weather = (
{
description = "clear sky";
icon = 01n;
id = 800;
main = Clear;
}
);
wind = {
deg = "330.501";
speed = "7.92";
};
},
{
clouds = {
all = 0;
};
dt = 1553331600;
"dt_txt" = "2019-03-23 09:00:00";
main = {
"grnd_level" = "984.45";
humidity = 65;
pressure = "1019.22";
"sea_level" = "1019.22";
temp = "-6.83";
"temp_kf" = "0.03";
"temp_max" = "-6.83";
"temp_min" = "-6.86";
};
snow = {
};
sys = {
pod = n;
};
weather = (
{
description = "clear sky";
icon = 01n;
id = 800;
main = Clear;
}
);
wind = {
deg = "326.501";
speed = "6.67";
};
},

Up 0 rated Down
Pavel Zuykov Mar 25, 2019 07:46AM GMT OpenWeatherMap Agent

Hello,

What software do you use to get data? Because data format isn’t the same like our raw outputs from API, you can compare it with our API documentation.

Up 0 rated Down
Keih Francis Mar 26, 2019 12:09AM GMT
Hello Pavel, I'm using Swift 4.2 with xcode 10.1. I download two JSONs, the current weather and the 5 day forecast and neither JSON contains [] but they do contain ().

Post Your Public Answer

Your name (required)
Your email address (required)
Answer (required)
9eda11838f597e7a95b6a1c991dcae0a@openweathermap.desk-mail.com
https://cdn.desk.com/
false
desk
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete