mholt / json-to-go

Translates JSON into a Go type in your browser instantly (original)
https://mholt.github.io/json-to-go/
MIT License
4.5k stars 474 forks source link

Incorrect Struct with JSONs which have the same key. #117

Open piqoni opened 2 years ago

piqoni commented 2 years ago

This JSON:

{"type":"Feature","geometry":{"type":"Point","coordinates":[12.51,54.67,0]},"properties":{"meta":{"updated_at":"2022-07-23T18:38:24Z","units":{"air_pressure_at_sea_level":"hPa","air_temperature":"celsius","cloud_area_fraction":"%","precipitation_amount":"mm","relative_humidity":"%","wind_from_direction":"degrees","wind_speed":"m/s"}},"timeseries":[{"time":"2022-07-23T19:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1016.7,"air_temperature":17.8,"cloud_area_fraction":99.5,"relative_humidity":71.6,"wind_from_direction":289.4,"wind_speed":6.2}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_1_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"partlycloudy_night"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-23T20:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1017.0,"air_temperature":17.8,"cloud_area_fraction":98.9,"relative_humidity":70.4,"wind_from_direction":284.4,"wind_speed":7.0}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_1_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"partlycloudy_night"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-23T21:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1017.6,"air_temperature":17.4,"cloud_area_fraction":74.1,"relative_humidity":69.0,"wind_from_direction":286.5,"wind_speed":8.5}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_1_hours":{"summary":{"symbol_code":"partlycloudy_night"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"fair_night"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-23T22:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1017.9,"air_temperature":17.0,"cloud_area_fraction":80.8,"relative_humidity":71.0,"wind_from_direction":288.5,"wind_speed":7.8}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_1_hours":{"summary":{"symbol_code":"partlycloudy_night"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"fair_night"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-23T23:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1018.1,"air_temperature":16.5,"cloud_area_fraction":54.8,"relative_humidity":73.5,"wind_from_direction":291.8,"wind_speed":7.3}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_1_hours":{"summary":{"symbol_code":"partlycloudy_night"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"fair_night"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T00:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1018.0,"air_temperature":16.3,"cloud_area_fraction":19.8,"relative_humidity":75.9,"wind_from_direction":286.9,"wind_speed":8.5}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_1_hours":{"summary":{"symbol_code":"fair_night"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"fair_night"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T01:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1018.2,"air_temperature":16.1,"cloud_area_fraction":19.1,"relative_humidity":76.1,"wind_from_direction":291.6,"wind_speed":7.8}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_1_hours":{"summary":{"symbol_code":"fair_night"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"fair_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T02:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1018.3,"air_temperature":15.9,"cloud_area_fraction":7.8,"relative_humidity":74.3,"wind_from_direction":300.0,"wind_speed":7.2}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_1_hours":{"summary":{"symbol_code":"clearsky_night"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"fair_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T03:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1018.4,"air_temperature":15.7,"cloud_area_fraction":11.7,"relative_humidity":73.2,"wind_from_direction":298.9,"wind_speed":6.9}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_1_hours":{"summary":{"symbol_code":"clearsky_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"fair_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T04:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1018.5,"air_temperature":15.5,"cloud_area_fraction":29.5,"relative_humidity":73.6,"wind_from_direction":297.0,"wind_speed":6.6}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_1_hours":{"summary":{"symbol_code":"fair_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"fair_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T05:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1018.9,"air_temperature":15.4,"cloud_area_fraction":47.4,"relative_humidity":74.0,"wind_from_direction":293.8,"wind_speed":6.2}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_1_hours":{"summary":{"symbol_code":"partlycloudy_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"fair_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T06:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1019.1,"air_temperature":15.3,"cloud_area_fraction":56.4,"relative_humidity":74.9,"wind_from_direction":287.7,"wind_speed":5.8}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_1_hours":{"summary":{"symbol_code":"partlycloudy_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"fair_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T07:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1019.3,"air_temperature":15.3,"cloud_area_fraction":29.3,"relative_humidity":74.7,"wind_from_direction":284.4,"wind_speed":5.1}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_1_hours":{"summary":{"symbol_code":"fair_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"fair_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T08:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1019.3,"air_temperature":15.6,"cloud_area_fraction":2.3,"relative_humidity":74.0,"wind_from_direction":263.2,"wind_speed":4.0}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_1_hours":{"summary":{"symbol_code":"clearsky_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"fair_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T09:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1019.5,"air_temperature":16.0,"cloud_area_fraction":8.2,"relative_humidity":74.1,"wind_from_direction":248.2,"wind_speed":4.4}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_1_hours":{"summary":{"symbol_code":"clearsky_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"partlycloudy_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T10:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1019.4,"air_temperature":16.3,"cloud_area_fraction":2.2,"relative_humidity":76.1,"wind_from_direction":230.8,"wind_speed":5.3}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_1_hours":{"summary":{"symbol_code":"clearsky_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"partlycloudy_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T11:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1019.0,"air_temperature":16.5,"cloud_area_fraction":0.0,"relative_humidity":76.9,"wind_from_direction":224.4,"wind_speed":5.5}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_1_hours":{"summary":{"symbol_code":"clearsky_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"partlycloudy_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T12:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1018.7,"air_temperature":16.7,"cloud_area_fraction":39.9,"relative_humidity":75.4,"wind_from_direction":227.3,"wind_speed":5.2}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_1_hours":{"summary":{"symbol_code":"partlycloudy_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"partlycloudy_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T13:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1018.3,"air_temperature":17.1,"cloud_area_fraction":97.4,"relative_humidity":75.4,"wind_from_direction":220.3,"wind_speed":3.3}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_1_hours":{"summary":{"symbol_code":"partlycloudy_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"partlycloudy_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T14:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1017.7,"air_temperature":17.4,"cloud_area_fraction":71.1,"relative_humidity":76.7,"wind_from_direction":189.6,"wind_speed":2.0}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_1_hours":{"summary":{"symbol_code":"partlycloudy_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T15:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1017.0,"air_temperature":17.6,"cloud_area_fraction":43.3,"relative_humidity":80.2,"wind_from_direction":139.4,"wind_speed":3.0}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_1_hours":{"summary":{"symbol_code":"partlycloudy_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T16:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1016.5,"air_temperature":18.0,"cloud_area_fraction":99.6,"relative_humidity":82.1,"wind_from_direction":127.3,"wind_speed":3.9}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_1_hours":{"summary":{"symbol_code":"partlycloudy_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T17:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1015.9,"air_temperature":18.3,"cloud_area_fraction":100.0,"relative_humidity":82.3,"wind_from_direction":134.2,"wind_speed":4.8}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_1_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T18:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1015.5,"air_temperature":18.4,"cloud_area_fraction":100.0,"relative_humidity":84.3,"wind_from_direction":141.1,"wind_speed":5.4}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_night"}},"next_1_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"partlycloudy_night"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T19:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1015.5,"air_temperature":19.4,"cloud_area_fraction":100.0,"relative_humidity":77.2,"wind_from_direction":137.6,"wind_speed":4.8}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_1_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"partlycloudy_night"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T20:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1015.4,"air_temperature":19.1,"cloud_area_fraction":99.9,"relative_humidity":81.0,"wind_from_direction":142.0,"wind_speed":4.9}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_1_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"partlycloudy_night"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T21:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1015.3,"air_temperature":19.0,"cloud_area_fraction":91.0,"relative_humidity":81.6,"wind_from_direction":140.0,"wind_speed":4.3}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_1_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"partlycloudy_night"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T22:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1015.0,"air_temperature":18.7,"cloud_area_fraction":93.1,"relative_humidity":84.7,"wind_from_direction":115.2,"wind_speed":4.0}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_1_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"fair_night"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-24T23:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1014.8,"air_temperature":18.7,"cloud_area_fraction":69.3,"relative_humidity":85.7,"wind_from_direction":160.8,"wind_speed":3.9}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_1_hours":{"summary":{"symbol_code":"partlycloudy_night"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"fair_night"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-25T00:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1014.3,"air_temperature":19.0,"cloud_area_fraction":47.4,"relative_humidity":80.6,"wind_from_direction":171.3,"wind_speed":5.2}},"next_12_hours":{"summary":{"symbol_code":"clearsky_day"}},"next_1_hours":{"summary":{"symbol_code":"partlycloudy_night"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"fair_night"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-25T01:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1013.9,"air_temperature":19.5,"cloud_area_fraction":14.2,"relative_humidity":76.2,"wind_from_direction":184.2,"wind_speed":6.2}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_1_hours":{"summary":{"symbol_code":"fair_night"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"fair_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-25T02:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1013.6,"air_temperature":19.6,"cloud_area_fraction":6.2,"relative_humidity":76.0,"wind_from_direction":190.8,"wind_speed":6.3}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_1_hours":{"summary":{"symbol_code":"clearsky_night"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"fair_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-25T03:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1013.0,"air_temperature":19.3,"cloud_area_fraction":18.1,"relative_humidity":75.7,"wind_from_direction":178.7,"wind_speed":6.7}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_1_hours":{"summary":{"symbol_code":"fair_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"fair_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-25T04:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1012.3,"air_temperature":18.5,"cloud_area_fraction":33.4,"relative_humidity":81.9,"wind_from_direction":160.9,"wind_speed":5.7}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_1_hours":{"summary":{"symbol_code":"fair_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"clearsky_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-25T05:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1011.5,"air_temperature":18.5,"cloud_area_fraction":12.4,"relative_humidity":78.5,"wind_from_direction":171.5,"wind_speed":5.7}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_1_hours":{"summary":{"symbol_code":"clearsky_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"clearsky_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-25T06:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1011.0,"air_temperature":19.1,"cloud_area_fraction":11.2,"relative_humidity":73.4,"wind_from_direction":184.3,"wind_speed":6.5}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_1_hours":{"summary":{"symbol_code":"clearsky_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"clearsky_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-25T07:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1010.7,"air_temperature":19.5,"cloud_area_fraction":9.3,"relative_humidity":72.9,"wind_from_direction":189.7,"wind_speed":6.7}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_1_hours":{"summary":{"symbol_code":"clearsky_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"fair_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-25T08:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1010.3,"air_temperature":20.0,"cloud_area_fraction":10.6,"relative_humidity":72.2,"wind_from_direction":187.6,"wind_speed":6.2}},"next_12_hours":{"summary":{"symbol_code":"lightrainshowers_day"}},"next_1_hours":{"summary":{"symbol_code":"clearsky_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"fair_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-25T09:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1010.2,"air_temperature":20.2,"cloud_area_fraction":6.1,"relative_humidity":73.8,"wind_from_direction":167.8,"wind_speed":4.8}},"next_12_hours":{"summary":{"symbol_code":"lightrainshowers_day"}},"next_1_hours":{"summary":{"symbol_code":"clearsky_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"partlycloudy_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-25T10:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1009.6,"air_temperature":20.5,"cloud_area_fraction":3.6,"relative_humidity":74.5,"wind_from_direction":156.2,"wind_speed":5.0}},"next_12_hours":{"summary":{"symbol_code":"rainshowersandthunder_day"}},"next_1_hours":{"summary":{"symbol_code":"clearsky_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"partlycloudy_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-25T11:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1008.7,"air_temperature":20.9,"cloud_area_fraction":19.0,"relative_humidity":71.7,"wind_from_direction":144.5,"wind_speed":5.3}},"next_12_hours":{"summary":{"symbol_code":"rainandthunder"}},"next_1_hours":{"summary":{"symbol_code":"fair_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"partlycloudy_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-25T12:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1007.6,"air_temperature":21.5,"cloud_area_fraction":0.1,"relative_humidity":68.8,"wind_from_direction":151.3,"wind_speed":4.6}},"next_12_hours":{"summary":{"symbol_code":"rainandthunder"}},"next_1_hours":{"summary":{"symbol_code":"clearsky_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-25T13:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1006.7,"air_temperature":21.9,"cloud_area_fraction":80.8,"relative_humidity":67.6,"wind_from_direction":149.7,"wind_speed":4.4}},"next_1_hours":{"summary":{"symbol_code":"partlycloudy_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-25T14:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1005.7,"air_temperature":22.1,"cloud_area_fraction":98.8,"relative_humidity":66.2,"wind_from_direction":147.3,"wind_speed":5.0}},"next_1_hours":{"summary":{"symbol_code":"partlycloudy_day"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"rain"},"details":{"precipitation_amount":1.2}}}},{"time":"2022-07-25T15:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1004.8,"air_temperature":22.0,"cloud_area_fraction":100.0,"relative_humidity":66.9,"wind_from_direction":144.7,"wind_speed":5.0}},"next_1_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"rain"},"details":{"precipitation_amount":3.1}}}},{"time":"2022-07-25T16:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1003.8,"air_temperature":22.1,"cloud_area_fraction":90.9,"relative_humidity":66.5,"wind_from_direction":152.3,"wind_speed":5.2}},"next_1_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"heavyrainandthunder"},"details":{"precipitation_amount":8.1}}}},{"time":"2022-07-25T17:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1003.0,"air_temperature":22.0,"cloud_area_fraction":91.2,"relative_humidity":67.9,"wind_from_direction":155.5,"wind_speed":4.9}},"next_1_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"heavyrainandthunder"},"details":{"precipitation_amount":9.1}}}},{"time":"2022-07-25T18:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1003.7,"air_temperature":21.8,"cloud_area_fraction":93.0,"relative_humidity":70.9,"wind_from_direction":285.6,"wind_speed":10.9}},"next_12_hours":{"summary":{"symbol_code":"lightrainshowers_day"}},"next_1_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}},"next_6_hours":{"summary":{"symbol_code":"heavyrainandthunder"},"details":{"precipitation_amount":9.1}}}},{"time":"2022-07-25T19:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1004.6,"air_temperature":19.6,"cloud_area_fraction":100.0,"relative_humidity":91.0,"wind_from_direction":307.5,"wind_speed":6.2}},"next_1_hours":{"summary":{"symbol_code":"rain"},"details":{"precipitation_amount":0.8}}}},{"time":"2022-07-25T20:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1004.6,"air_temperature":19.5,"cloud_area_fraction":99.2,"relative_humidity":93.1,"wind_from_direction":315.1,"wind_speed":3.2}},"next_1_hours":{"summary":{"symbol_code":"heavyrain"},"details":{"precipitation_amount":2.0}}}},{"time":"2022-07-25T21:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1005.2,"air_temperature":18.6,"cloud_area_fraction":100.0,"relative_humidity":95.6,"wind_from_direction":281.3,"wind_speed":6.1}},"next_1_hours":{"summary":{"symbol_code":"heavyrainandthunder"},"details":{"precipitation_amount":4.3}}}},{"time":"2022-07-25T22:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1005.6,"air_temperature":18.4,"cloud_area_fraction":100.0,"relative_humidity":96.7,"wind_from_direction":238.1,"wind_speed":5.3}},"next_1_hours":{"summary":{"symbol_code":"heavyrain"},"details":{"precipitation_amount":1.9}}}},{"time":"2022-07-25T23:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1005.6,"air_temperature":17.9,"cloud_area_fraction":100.0,"relative_humidity":95.5,"wind_from_direction":257.1,"wind_speed":9.1}},"next_1_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-26T00:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1005.4,"air_temperature":18.0,"cloud_area_fraction":100.0,"relative_humidity":94.1,"wind_from_direction":250.8,"wind_speed":8.9}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_6_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-26T06:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1006.6,"air_temperature":17.4,"cloud_area_fraction":43.4,"relative_humidity":84.6,"wind_from_direction":257.8,"wind_speed":9.1}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_6_hours":{"summary":{"symbol_code":"partlycloudy_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-26T12:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1009.3,"air_temperature":18.2,"cloud_area_fraction":40.2,"relative_humidity":73.3,"wind_from_direction":269.5,"wind_speed":10.0}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_6_hours":{"summary":{"symbol_code":"partlycloudy_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-26T18:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1010.6,"air_temperature":16.8,"cloud_area_fraction":26.6,"relative_humidity":69.6,"wind_from_direction":275.4,"wind_speed":11.4}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_night"}},"next_6_hours":{"summary":{"symbol_code":"fair_night"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-27T00:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1012.1,"air_temperature":15.2,"cloud_area_fraction":43.4,"relative_humidity":76.6,"wind_from_direction":273.8,"wind_speed":12.2}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_6_hours":{"summary":{"symbol_code":"partlycloudy_night"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-27T06:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1012.5,"air_temperature":15.0,"cloud_area_fraction":96.1,"relative_humidity":74.0,"wind_from_direction":282.1,"wind_speed":12.2}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_6_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-27T12:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1014.4,"air_temperature":16.7,"cloud_area_fraction":100.0,"relative_humidity":66.0,"wind_from_direction":275.1,"wind_speed":11.1}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_6_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-27T18:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1015.1,"air_temperature":16.6,"cloud_area_fraction":45.3,"relative_humidity":63.0,"wind_from_direction":286.3,"wind_speed":10.1}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_night"}},"next_6_hours":{"summary":{"symbol_code":"partlycloudy_night"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-28T00:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1017.1,"air_temperature":14.6,"cloud_area_fraction":40.2,"relative_humidity":70.8,"wind_from_direction":296.7,"wind_speed":8.2}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_6_hours":{"summary":{"symbol_code":"partlycloudy_night"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-28T06:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1018.0,"air_temperature":14.5,"cloud_area_fraction":41.4,"relative_humidity":70.7,"wind_from_direction":293.3,"wind_speed":6.6}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_6_hours":{"summary":{"symbol_code":"partlycloudy_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-28T12:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1019.7,"air_temperature":16.5,"cloud_area_fraction":98.0,"relative_humidity":59.6,"wind_from_direction":275.4,"wind_speed":4.2}},"next_12_hours":{"summary":{"symbol_code":"cloudy"}},"next_6_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-28T18:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1019.5,"air_temperature":16.9,"cloud_area_fraction":97.7,"relative_humidity":57.5,"wind_from_direction":264.9,"wind_speed":3.4}},"next_12_hours":{"summary":{"symbol_code":"cloudy"}},"next_6_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-29T00:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1021.3,"air_temperature":16.2,"cloud_area_fraction":99.2,"relative_humidity":60.5,"wind_from_direction":124.1,"wind_speed":3.0}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_6_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-29T06:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1021.5,"air_temperature":16.4,"cloud_area_fraction":100.0,"relative_humidity":71.3,"wind_from_direction":112.1,"wind_speed":2.4}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_6_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-29T12:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1022.4,"air_temperature":16.6,"cloud_area_fraction":15.6,"relative_humidity":69.8,"wind_from_direction":73.1,"wind_speed":3.8}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_6_hours":{"summary":{"symbol_code":"fair_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-29T18:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1021.9,"air_temperature":16.9,"cloud_area_fraction":8.2,"relative_humidity":66.7,"wind_from_direction":83.4,"wind_speed":2.9}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_6_hours":{"summary":{"symbol_code":"clearsky_night"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-30T00:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1020.1,"air_temperature":16.6,"cloud_area_fraction":100.0,"relative_humidity":79.8,"wind_from_direction":75.5,"wind_speed":5.5}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_6_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-30T06:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1022.2,"air_temperature":16.6,"cloud_area_fraction":1.6,"relative_humidity":77.7,"wind_from_direction":64.4,"wind_speed":3.4}},"next_12_hours":{"summary":{"symbol_code":"clearsky_day"}},"next_6_hours":{"summary":{"symbol_code":"clearsky_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-30T12:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1022.7,"air_temperature":17.1,"cloud_area_fraction":8.2,"relative_humidity":78.6,"wind_from_direction":70.4,"wind_speed":3.8}},"next_12_hours":{"summary":{"symbol_code":"clearsky_day"}},"next_6_hours":{"summary":{"symbol_code":"clearsky_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-30T18:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1021.3,"air_temperature":17.2,"cloud_area_fraction":8.6,"relative_humidity":75.0,"wind_from_direction":98.3,"wind_speed":3.7}},"next_12_hours":{"summary":{"symbol_code":"clearsky_night"}},"next_6_hours":{"summary":{"symbol_code":"clearsky_night"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-31T00:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1021.2,"air_temperature":16.9,"cloud_area_fraction":11.7,"relative_humidity":79.3,"wind_from_direction":143.9,"wind_speed":3.2}},"next_12_hours":{"summary":{"symbol_code":"clearsky_day"}},"next_6_hours":{"summary":{"symbol_code":"clearsky_night"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-31T06:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1020.9,"air_temperature":17.1,"cloud_area_fraction":5.5,"relative_humidity":83.9,"wind_from_direction":138.5,"wind_speed":3.3}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_6_hours":{"summary":{"symbol_code":"clearsky_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-31T12:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1020.9,"air_temperature":18.2,"cloud_area_fraction":10.9,"relative_humidity":80.2,"wind_from_direction":204.6,"wind_speed":3.5}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_6_hours":{"summary":{"symbol_code":"clearsky_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-07-31T18:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1017.2,"air_temperature":18.1,"cloud_area_fraction":97.7,"relative_humidity":78.9,"wind_from_direction":222.5,"wind_speed":3.7}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_6_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-08-01T00:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1017.8,"air_temperature":17.6,"cloud_area_fraction":12.1,"relative_humidity":79.4,"wind_from_direction":270.4,"wind_speed":3.4}},"next_12_hours":{"summary":{"symbol_code":"fair_day"}},"next_6_hours":{"summary":{"symbol_code":"clearsky_night"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-08-01T06:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1018.5,"air_temperature":17.4,"cloud_area_fraction":11.7,"relative_humidity":84.8,"wind_from_direction":245.1,"wind_speed":3.8}},"next_12_hours":{"summary":{"symbol_code":"partlycloudy_day"}},"next_6_hours":{"summary":{"symbol_code":"clearsky_day"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-08-01T12:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1017.4,"air_temperature":18.3,"cloud_area_fraction":99.2,"relative_humidity":74.5,"wind_from_direction":236.5,"wind_speed":3.9}},"next_6_hours":{"summary":{"symbol_code":"cloudy"},"details":{"precipitation_amount":0.0}}}},{"time":"2022-08-01T18:00:00Z","data":{"instant":{"details":{"air_pressure_at_sea_level":1016.0,"air_temperature":18.6,"cloud_area_fraction":100.0,"relative_humidity":73.0,"wind_from_direction":243.6,"wind_speed":3.9}}}}]}}

Generates a struct with multiple Data0, Data1, Data2 structs inside. (Cannot put it here as Github complains about it being too big)

Expected Output:

type AutoGenerated struct {
    Type     string `json:"type"`
    Geometry struct {
        Type        string `json:"type"`
        Coordinates []int  `json:"coordinates"`
    } `json:"geometry"`
    Properties struct {
        Meta struct {
            UpdatedAt time.Time `json:"updated_at"`
            Units     struct {
                AirPressureAtSeaLevel string `json:"air_pressure_at_sea_level"`
                AirTemperature        string `json:"air_temperature"`
                CloudAreaFraction     string `json:"cloud_area_fraction"`
                PrecipitationAmount   string `json:"precipitation_amount"`
                RelativeHumidity      string `json:"relative_humidity"`
                WindFromDirection     string `json:"wind_from_direction"`
                WindSpeed             string `json:"wind_speed"`
            } `json:"units"`
        } `json:"meta"`
        Timeseries []struct {
            Time time.Time `json:"time"`
            Data struct {
                Instant struct {
                    Details struct {
                        AirPressureAtSeaLevel float64 `json:"air_pressure_at_sea_level"`
                        AirTemperature        float64 `json:"air_temperature"`
                        CloudAreaFraction     float64 `json:"cloud_area_fraction"`
                        RelativeHumidity      float64 `json:"relative_humidity"`
                        WindFromDirection     float64 `json:"wind_from_direction"`
                        WindSpeed             float64 `json:"wind_speed"`
                    } `json:"details"`
                } `json:"instant"`
                Next12Hours struct {
                    Summary struct {
                        SymbolCode string `json:"symbol_code"`
                    } `json:"summary"`
                } `json:"next_12_hours"`
                Next1Hours struct {
                    Summary struct {
                        SymbolCode string `json:"symbol_code"`
                    } `json:"summary"`
                    Details struct {
                        PrecipitationAmount float64 `json:"precipitation_amount"`
                    } `json:"details"`
                } `json:"next_1_hours"`
                Next6Hours struct {
                    Summary struct {
                        SymbolCode string `json:"symbol_code"`
                    } `json:"summary"`
                    Details struct {
                        PrecipitationAmount float64 `json:"precipitation_amount"`
                    } `json:"details"`
                } `json:"next_6_hours"`
            } `json:"data"`
        } `json:"timeseries"`
    } `json:"properties"`
}
mholt commented 2 years ago

Oh... that's tricky. It's probably because the "data" structs don't have exactly the same fields. Or something like that.

I'm a bit swamped with other things right now but I'd welcome a pull request to patch this! (Preferably one that simplifies existing code rather than adding complexity, if possible. It's likelhy an earlier version of this script doesn't have this bug; it'd be useful to know where the bug was introduced.)

grische commented 3 months ago

@piqoni I cannot reproduce this. Can you upload a gist (https://gist.github.com) and share both the unexpected go as well as the full json?