That was it, i had a few more errors of the same type with other structs, but then i followed your advice and everything works now. Thank you!
On Thursday, June 29, 2017 at 3:42:24 PM UTC+3, C Banning wrote: > > Try: > >> type ParticipantIty struct { >> ParticipantId int >> Player Player >> } >> > > On Thursday, June 29, 2017 at 6:10:03 AM UTC-6, Martin Spasov wrote: >> >> Hey guys, >> >> I have been trying to decode a json object into a struct with nested >> structs. When the struct is 1 level deep it does not create problems, but >> if i have a struct with an attribute that is a struct i get the error >> present in the title. Here is part of the code : >> >> Json : >> >> { >> "seasonId": 8, >> "queueId": 420, >> "gameId": 3239663966, >> "participantIdentities": [ >> { >> "player": { >> "currentPlatformId": "EUW1", >> "summonerName": "MineManuDeYutu", >> "matchHistoryUri": >> "/v1/stats/player_history/EUW1/219194561", >> "platformId": "EUW1", >> "currentAccountId": 219194561, >> "profileIcon": 1666, >> "summonerId": 68726031, >> "accountId": 219194561 >> }, >> "participantId": 1 >> }, >> { >> "player": { >> "currentPlatformId": "EUW1", >> "summonerName": "Just Deadly", >> "matchHistoryUri": >> "/v1/stats/player_history/EUW1/205050256", >> "platformId": "EUW1", >> "currentAccountId": 205050256, >> "profileIcon": 1666, >> "summonerId": 47317494, >> "accountId": 205050256 >> }, >> "participantId": 2 >> }, >> { >> "player": { >> "currentPlatformId": "EUW1", >> "summonerName": "CougarHunting", >> "matchHistoryUri": >> "/v1/stats/player_history/EUW1/36397748", >> "platformId": "EUW1", >> "currentAccountId": 36397748, >> "profileIcon": 1666, >> "summonerId": 32741461, >> "accountId": 36397748 >> }, >> "participantId": 3 >> }, >> { >> "player": { >> "currentPlatformId": "EUW1", >> "summonerName": "Loca111", >> "matchHistoryUri": >> "/v1/stats/player_history/EUW1/231580371", >> "platformId": "EUW1", >> "currentAccountId": 231580371, >> "profileIcon": 1665, >> "summonerId": 96106805, >> "accountId": 231580371 >> }, >> "participantId": 4 >> }, >> { >> "player": { >> "currentPlatformId": "EUW1", >> "summonerName": "BoostedRiven420", >> "matchHistoryUri": >> "/v1/stats/player_history/EUW1/231287442", >> "platformId": "EUW1", >> "currentAccountId": 231287442, >> "profileIcon": 1665, >> "summonerId": 95496854, >> "accountId": 231287442 >> }, >> "participantId": 5 >> }, >> { >> "player": { >> "currentPlatformId": "EUW1", >> "summonerName": "Hroom", >> "matchHistoryUri": >> "/v1/stats/player_history/EUW1/217895755", >> "platformId": "EUW1", >> "currentAccountId": 217895755, >> "profileIcon": 1665, >> "summonerId": 66941009, >> "accountId": 217895755 >> }, >> "participantId": 6 >> }, >> { >> "player": { >> "currentPlatformId": "EUW1", >> "summonerName": "Nyss3", >> "matchHistoryUri": >> "/v1/stats/player_history/EUW1/22525212", >> "platformId": "EUW1", >> "currentAccountId": 22525212, >> "profileIcon": 1665, >> "summonerId": 19693763, >> "accountId": 22525212 >> }, >> "participantId": 7 >> }, >> { >> "player": { >> "currentPlatformId": "EUW1", >> "summonerName": "Number2333", >> "matchHistoryUri": >> "/v1/stats/player_history/EUW1/225600988", >> "platformId": "EUW1", >> "currentAccountId": 225600988, >> "profileIcon": 1665, >> "summonerId": 82017867, >> "accountId": 225600988 >> }, >> "participantId": 8 >> }, >> { >> "player": { >> "currentPlatformId": "EUW1", >> "summonerName": "Asianpowerbabe", >> "matchHistoryUri": >> "/v1/stats/player_history/EUW1/204195645", >> "platformId": "EUW1", >> "currentAccountId": 204195645, >> "profileIcon": 1665, >> "summonerId": 45862904, >> "accountId": 204195645 >> }, >> "participantId": 9 >> }, >> { >> "player": { >> "currentPlatformId": "EUW1", >> "summonerName": "DynastyBeast", >> "matchHistoryUri": >> "/v1/stats/player_history/EUW1/39635851", >> "platformId": "EUW1", >> "currentAccountId": 39635851, >> "profileIcon": 1666, >> "summonerId": 36712797, >> "accountId": 39635851 >> }, >> "participantId": 10 >> } >> ], >> "gameVersion": "7.12.190.9002", >> "platformId": "EUW1", >> "gameMode": "CLASSIC", >> "mapId": 11, >> "gameType": "MATCHED_GAME", >> >> >> Code : >> >> >> type DetailedMatch struct { >> SeasonId int >> QueueId int >> GameId int >> ParticipantIdentities []ParticipantIty >> GameVersion string >> PlatformId string >> GameMode string >> MapId int >> GameType string >> Teams []Team >> Participants json.RawMessage >> GameDuration int >> GameCreation int >> } >> >> type ParticipantIty struct { >> ParticipantId int >> Player []Player >> } >> >> type Player struct { >> CurrentPlatformId string `json:"currentPlatformId"` >> SummonerName string `json:"summonerName"` >> MatchHistoryUri string `json:"matchHistoryUri"` >> PlatformId string `json:"platformId"` >> CurrentAccountId int `json:"currentAccountId"` >> ProfileIcon int `json:"profileIcon"` >> SummonerId int `json:"summonerId"` >> AccountId int `json:"accountId"` >> } >> >> The code where i call the marshal >> >> >> func GetMatchById(matchId string, server string) (*DetailedMatch, >> error) { >> var Response, err = http.Get(fmt.Sprintf(ENDPOINT_MATCH_BY_GAME_ID, >> server, matchId, string(KEY))) >> var Details = DetailedMatch{} >> >> if err != nil { >> fmt.Println(123) >> return &Details, err >> } else { >> var ByteResponse, ByteError = ioutil.ReadAll(Response.Body) >> if ByteError != nil { >> fmt.Println(124) >> return &Details, ByteError >> } else { >> var UnmarshalError = json.Unmarshal(ByteResponse, &Details) >> if UnmarshalError != nil { >> fmt.Println(UnmarshalError) >> return &Details, UnmarshalError >> } else { >> return &Details, nil >> } >> } >> } >> } >> >> >> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.