Skip to content

Commit 5cc0ee7

Browse files
authored
feat: migrate from json-iterator/json to goccy/go-json (#76)
- switched to goccy/go-json for better long-term support, compatibility, performance, and consistency - json-iterator is no longer a fully compatible replacement for encoding/json and its updates have slowed down
1 parent f1e09a7 commit 5cc0ee7

File tree

7 files changed

+42
-55
lines changed

7 files changed

+42
-55
lines changed

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ module github.com/cyruzin/golang-tmdb
33
go 1.24
44

55
require (
6-
github.com/json-iterator/go v1.1.12
6+
github.com/goccy/go-json v0.10.5
77
github.com/stretchr/testify v1.10.0
88
)
99

1010
require (
1111
github.com/davecgh/go-spew v1.1.1 // indirect
12-
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
13-
github.com/modern-go/reflect2 v1.0.2 // indirect
1412
github.com/pmezard/go-difflib v1.0.0 // indirect
1513
gopkg.in/yaml.v3 v3.0.1 // indirect
1614
)

go.sum

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
1-
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
21
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
32
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4-
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
5-
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
6-
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
7-
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
8-
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
9-
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
10-
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
11-
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
3+
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
4+
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
125
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
136
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
14-
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
15-
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
167
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
178
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
189
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=

movies.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"net/http"
66

7-
jsoniter "github.com/json-iterator/go"
7+
json "github.com/goccy/go-json"
88
)
99

1010
// MovieDetails type is a struct for movie details JSON response.
@@ -157,10 +157,10 @@ func (c *Client) GetMovieDetails(
157157

158158
// MovieAccountStates type is a struct for account states JSON response.
159159
type MovieAccountStates struct {
160-
ID int64 `json:"id"`
161-
Favorite bool `json:"favorite"`
162-
Rated jsoniter.RawMessage `json:"rated"`
163-
Watchlist bool `json:"watchlist"`
160+
ID int64 `json:"id"`
161+
Favorite bool `json:"favorite"`
162+
Rated json.RawMessage `json:"rated"`
163+
Watchlist bool `json:"watchlist"`
164164
}
165165

166166
// GetMovieAccountStates grab the following account states for a session:
@@ -230,12 +230,12 @@ type MovieChanges struct {
230230
Changes []struct {
231231
Key string `json:"key"`
232232
Items []struct {
233-
ID jsoniter.RawMessage `json:"id"`
234-
Action jsoniter.RawMessage `json:"action"`
235-
Time jsoniter.RawMessage `json:"time"`
236-
Iso639_1 jsoniter.RawMessage `json:"iso_639_1"`
237-
Value jsoniter.RawMessage `json:"value"`
238-
OriginalValue jsoniter.RawMessage `json:"original_value"`
233+
ID json.RawMessage `json:"id"`
234+
Action json.RawMessage `json:"action"`
235+
Time json.RawMessage `json:"time"`
236+
Iso639_1 json.RawMessage `json:"iso_639_1"`
237+
Value json.RawMessage `json:"value"`
238+
OriginalValue json.RawMessage `json:"original_value"`
239239
} `json:"items"`
240240
} `json:"changes"`
241241
}

tmdb.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ import (
1414
"strconv"
1515
"time"
1616

17-
jsoniter "github.com/json-iterator/go"
17+
json "github.com/goccy/go-json"
1818
)
1919

20-
var json = jsoniter.ConfigFastest
21-
2220
// TMDb constants
2321
const (
2422
defaultBaseURL = "https://api.themoviedb.org/3"

tv.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"net/http"
66

7-
jsoniter "github.com/json-iterator/go"
7+
json "github.com/goccy/go-json"
88
)
99

1010
// TVDetails type is a struct for details JSON response.
@@ -182,10 +182,10 @@ func (c *Client) GetTVDetails(
182182

183183
// TVAccountStates type is a struct for account states JSON response.
184184
type TVAccountStates struct {
185-
ID int64 `json:"id"`
186-
Favorite bool `json:"favorite"`
187-
Rated jsoniter.RawMessage `json:"rated"`
188-
Watchlist bool `json:"watchlist"`
185+
ID int64 `json:"id"`
186+
Favorite bool `json:"favorite"`
187+
Rated json.RawMessage `json:"rated"`
188+
Watchlist bool `json:"watchlist"`
189189
}
190190

191191
// GetTVAccountStates grab the following account states for a session:
@@ -313,13 +313,13 @@ type TVChanges struct {
313313
Changes []struct {
314314
Key string `json:"key"`
315315
Items []struct {
316-
ID string `json:"id"`
317-
Action string `json:"action"`
318-
Time string `json:"time"`
319-
Iso639_1 string `json:"iso_639_1"`
320-
Iso3166_1 string `json:"iso_3166_1"`
321-
Value jsoniter.RawMessage `json:"value"`
322-
OriginalValue jsoniter.RawMessage `json:"original_value"`
316+
ID string `json:"id"`
317+
Action string `json:"action"`
318+
Time string `json:"time"`
319+
Iso639_1 string `json:"iso_639_1"`
320+
Iso3166_1 string `json:"iso_3166_1"`
321+
Value json.RawMessage `json:"value"`
322+
OriginalValue json.RawMessage `json:"original_value"`
323323
} `json:"items"`
324324
} `json:"changes"`
325325
}

tv_episode_groups.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package tmdb
33
import (
44
"fmt"
55

6-
jsoniter "github.com/json-iterator/go"
6+
json "github.com/goccy/go-json"
77
)
88

99
// TVEpisodeGroupsDetails type is a struct for details JSON response.
@@ -16,18 +16,18 @@ type TVEpisodeGroupsDetails struct {
1616
Name string `json:"name"`
1717
Order int `json:"order"`
1818
Episodes []struct {
19-
AirDate string `json:"air_date"`
20-
EpisodeNumber int `json:"episode_number"`
21-
ID int64 `json:"id"`
22-
Name string `json:"name"`
23-
Overview string `json:"overview"`
24-
ProductionCode jsoniter.RawMessage `json:"production_code"`
25-
SeasonNumber int `json:"season_number"`
26-
ShowID int64 `json:"show_id"`
27-
StillPath string `json:"still_path"`
28-
VoteAverage float32 `json:"vote_average"`
29-
VoteCount int64 `json:"vote_count"`
30-
Order int `json:"order"`
19+
AirDate string `json:"air_date"`
20+
EpisodeNumber int `json:"episode_number"`
21+
ID int64 `json:"id"`
22+
Name string `json:"name"`
23+
Overview string `json:"overview"`
24+
ProductionCode json.RawMessage `json:"production_code"`
25+
SeasonNumber int `json:"season_number"`
26+
ShowID int64 `json:"show_id"`
27+
StillPath string `json:"still_path"`
28+
VoteAverage float32 `json:"vote_average"`
29+
VoteCount int64 `json:"vote_count"`
30+
Order int `json:"order"`
3131
} `json:"episodes"`
3232
Locked bool `json:"locked"`
3333
} `json:"groups"`

tv_episodes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package tmdb
33
import (
44
"fmt"
55

6-
jsoniter "github.com/json-iterator/go"
6+
json "github.com/goccy/go-json"
77
)
88

99
// TVEpisodeDetails type is a struct for details JSON response.
@@ -121,7 +121,7 @@ type TVEpisodeChanges struct {
121121
Order int64 `json:"order"`
122122
CreditID string `json:"credit_id"`
123123
} `json:"original_values,omitempty"`
124-
Value jsoniter.RawMessage `json:"value,omitempty"`
124+
Value json.RawMessage `json:"value,omitempty"`
125125
} `json:"items"`
126126
} `json:"changes"`
127127
}

0 commit comments

Comments
 (0)