| 1 |
/* |
| 2 |
* Copyright 2021 ByteDance Inc. |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
* you may not use this file except in compliance with the License. |
| 6 |
* You may obtain a copy of the License at |
| 7 |
* |
| 8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
* |
| 10 |
* Unless required by applicable law or agreed to in writing, software |
| 11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
* See the License for the specific language governing permissions and |
| 14 |
* limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
// The benchmarks of the encoder of bytedance/sonic, with go-json beside it. |
| 18 |
// |
| 19 |
// The payload ( TwitterJson and the types of TwitterStruct ) is testdata/twitter.go of sonic v1.15.4, copied |
| 20 |
// as it is: a directory named testdata can't be imported. The benchmarks are the ones of sonic's |
| 21 |
// encoder/encoder_test.go, written for the libraries compared here. Both are the work of ByteDance Inc. under |
| 22 |
// the Apache License 2.0, whose text is in licenses/sonic-LICENSE; the rest of this repository is under its |
| 23 |
// own license ( see LICENSE at the root ). |
| 24 |
// |
| 25 |
// The benchmarks encode the payload as a value of interface{} ( Generic ) and as its struct ( Binding ), |
| 26 |
// one goroutine and in parallel: |
| 27 |
// |
| 28 |
// - Sonic is what sonic's BenchmarkEncoder_*_Sonic does: SortMapKeys, EscapeHTML and CompactMarshaler, |
| 29 |
// which is what go-json does by default, but for the normalization of UTF-8, which go-json also does by |
| 30 |
// default: GoJsonNoNormalize is go-json without it. |
| 31 |
// - SonicFast is what BenchmarkEncoder_*_Sonic_Fast does: no option. GoJsonLikeSonicFast is go-json with |
| 32 |
// the options which do the same: no sort of the keys, no escape of HTML, no normalization of UTF-8. |
| 33 |
// - StdLib is encoding/json, as in sonic. |
| 34 |
|
| 35 |
package benchmark |
| 36 |
|
| 37 |
import ( |
| 38 |
stdjson "encoding/json" |
| 39 |
"reflect" |
| 40 |
"testing" |
| 41 |
|
| 42 |
"github.com/bytedance/sonic" |
| 43 |
gojson "github.com/goccy/go-json" |
| 44 |
) |
| 45 |
|
| 46 |
var ( |
| 47 |
twitterGeneric any |
| 48 |
twitterBinding TwitterStruct |
| 49 |
sonicTwitter = sonic.Config{SortMapKeys: true, EscapeHTML: true, CompactMarshaler: true}.Froze() |
| 50 |
sonicTwitterFast = sonic.Config{}.Froze() |
| 51 |
noNormalizeOptions = []gojson.EncodeOptionFunc{gojson.DisableNormalizeUTF8()} |
| 52 |
) |
| 53 |
|
| 54 |
func init() { |
| 55 |
if err := stdjson.Unmarshal([]byte(TwitterJson), &twitterGeneric); err != nil { |
| 56 |
panic(err) |
| 57 |
} |
| 58 |
if err := stdjson.Unmarshal([]byte(TwitterJson), &twitterBinding); err != nil { |
| 59 |
panic(err) |
| 60 |
} |
| 61 |
sonicTypes = append(sonicTypes, reflect.TypeOf(&twitterBinding)) |
| 62 |
} |
| 63 |
|
| 64 |
func benchTwitter(b *testing.B, marshal func() ([]byte, error)) { |
| 65 |
if _, err := marshal(); err != nil { |
| 66 |
b.Fatal(err) |
| 67 |
} |
| 68 |
b.SetBytes(int64(len(TwitterJson))) |
| 69 |
b.ReportAllocs() |
| 70 |
b.ResetTimer() |
| 71 |
for i := 0; i < b.N; i++ { |
| 72 |
if _, err := marshal(); err != nil { |
| 73 |
b.Fatal(err) |
| 74 |
} |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
func benchTwitterParallel(b *testing.B, marshal func() ([]byte, error)) { |
| 79 |
if _, err := marshal(); err != nil { |
| 80 |
b.Fatal(err) |
| 81 |
} |
| 82 |
b.SetBytes(int64(len(TwitterJson))) |
| 83 |
b.ReportAllocs() |
| 84 |
b.ResetTimer() |
| 85 |
b.RunParallel(func(pb *testing.PB) { |
| 86 |
for pb.Next() { |
| 87 |
if _, err := marshal(); err != nil { |
| 88 |
b.Fatal(err) |
| 89 |
} |
| 90 |
} |
| 91 |
}) |
| 92 |
} |
| 93 |
|
| 94 |
func Benchmark_TwitterGeneric_Sonic(b *testing.B) { |
| 95 |
pretouchSonic() |
| 96 |
benchTwitter(b, func() ([]byte, error) { return sonicTwitter.Marshal(twitterGeneric) }) |
| 97 |
} |
| 98 |
|
| 99 |
func Benchmark_TwitterGeneric_SonicFast(b *testing.B) { |
| 100 |
pretouchSonic() |
| 101 |
benchTwitter(b, func() ([]byte, error) { return sonicTwitterFast.Marshal(twitterGeneric) }) |
| 102 |
} |
| 103 |
|
| 104 |
func Benchmark_TwitterGeneric_StdLib(b *testing.B) { |
| 105 |
benchTwitter(b, func() ([]byte, error) { return stdjson.Marshal(twitterGeneric) }) |
| 106 |
} |
| 107 |
|
| 108 |
func Benchmark_TwitterGeneric_GoJson(b *testing.B) { |
| 109 |
benchTwitter(b, func() ([]byte, error) { return gojson.Marshal(twitterGeneric) }) |
| 110 |
} |
| 111 |
|
| 112 |
func Benchmark_TwitterGeneric_GoJsonNoNormalize(b *testing.B) { |
| 113 |
benchTwitter(b, func() ([]byte, error) { return gojson.MarshalWithOption(twitterGeneric, noNormalizeOptions...) }) |
| 114 |
} |
| 115 |
|
| 116 |
func Benchmark_TwitterGeneric_GoJsonLikeSonicFast(b *testing.B) { |
| 117 |
benchTwitter(b, func() ([]byte, error) { return gojson.MarshalWithOption(twitterGeneric, likeSonicOptions...) }) |
| 118 |
} |
| 119 |
|
| 120 |
func Benchmark_TwitterBinding_Sonic(b *testing.B) { |
| 121 |
pretouchSonic() |
| 122 |
benchTwitter(b, func() ([]byte, error) { return sonicTwitter.Marshal(&twitterBinding) }) |
| 123 |
} |
| 124 |
|
| 125 |
func Benchmark_TwitterBinding_SonicFast(b *testing.B) { |
| 126 |
pretouchSonic() |
| 127 |
benchTwitter(b, func() ([]byte, error) { return sonicTwitterFast.Marshal(&twitterBinding) }) |
| 128 |
} |
| 129 |
|
| 130 |
func Benchmark_TwitterBinding_StdLib(b *testing.B) { |
| 131 |
benchTwitter(b, func() ([]byte, error) { return stdjson.Marshal(&twitterBinding) }) |
| 132 |
} |
| 133 |
|
| 134 |
func Benchmark_TwitterBinding_GoJson(b *testing.B) { |
| 135 |
benchTwitter(b, func() ([]byte, error) { return gojson.Marshal(&twitterBinding) }) |
| 136 |
} |
| 137 |
|
| 138 |
func Benchmark_TwitterBinding_GoJsonNoNormalize(b *testing.B) { |
| 139 |
benchTwitter(b, func() ([]byte, error) { return gojson.MarshalWithOption(&twitterBinding, noNormalizeOptions...) }) |
| 140 |
} |
| 141 |
|
| 142 |
func Benchmark_TwitterBinding_GoJsonLikeSonicFast(b *testing.B) { |
| 143 |
benchTwitter(b, func() ([]byte, error) { return gojson.MarshalWithOption(&twitterBinding, likeSonicOptions...) }) |
| 144 |
} |
| 145 |
|
| 146 |
func Benchmark_TwitterParallelGeneric_Sonic(b *testing.B) { |
| 147 |
pretouchSonic() |
| 148 |
benchTwitterParallel(b, func() ([]byte, error) { return sonicTwitter.Marshal(twitterGeneric) }) |
| 149 |
} |
| 150 |
|
| 151 |
func Benchmark_TwitterParallelGeneric_SonicFast(b *testing.B) { |
| 152 |
pretouchSonic() |
| 153 |
benchTwitterParallel(b, func() ([]byte, error) { return sonicTwitterFast.Marshal(twitterGeneric) }) |
| 154 |
} |
| 155 |
|
| 156 |
func Benchmark_TwitterParallelGeneric_StdLib(b *testing.B) { |
| 157 |
benchTwitterParallel(b, func() ([]byte, error) { return stdjson.Marshal(twitterGeneric) }) |
| 158 |
} |
| 159 |
|
| 160 |
func Benchmark_TwitterParallelGeneric_GoJson(b *testing.B) { |
| 161 |
benchTwitterParallel(b, func() ([]byte, error) { return gojson.Marshal(twitterGeneric) }) |
| 162 |
} |
| 163 |
|
| 164 |
func Benchmark_TwitterParallelGeneric_GoJsonLikeSonicFast(b *testing.B) { |
| 165 |
benchTwitterParallel(b, func() ([]byte, error) { return gojson.MarshalWithOption(twitterGeneric, likeSonicOptions...) }) |
| 166 |
} |
| 167 |
|
| 168 |
func Benchmark_TwitterParallelBinding_Sonic(b *testing.B) { |
| 169 |
pretouchSonic() |
| 170 |
benchTwitterParallel(b, func() ([]byte, error) { return sonicTwitter.Marshal(&twitterBinding) }) |
| 171 |
} |
| 172 |
|
| 173 |
func Benchmark_TwitterParallelBinding_SonicFast(b *testing.B) { |
| 174 |
pretouchSonic() |
| 175 |
benchTwitterParallel(b, func() ([]byte, error) { return sonicTwitterFast.Marshal(&twitterBinding) }) |
| 176 |
} |
| 177 |
|
| 178 |
func Benchmark_TwitterParallelBinding_StdLib(b *testing.B) { |
| 179 |
benchTwitterParallel(b, func() ([]byte, error) { return stdjson.Marshal(&twitterBinding) }) |
| 180 |
} |
| 181 |
|
| 182 |
func Benchmark_TwitterParallelBinding_GoJson(b *testing.B) { |
| 183 |
benchTwitterParallel(b, func() ([]byte, error) { return gojson.Marshal(&twitterBinding) }) |
| 184 |
} |
| 185 |
|
| 186 |
func Benchmark_TwitterParallelBinding_GoJsonLikeSonicFast(b *testing.B) { |
| 187 |
benchTwitterParallel(b, func() ([]byte, error) { return gojson.MarshalWithOption(&twitterBinding, likeSonicOptions...) }) |
| 188 |
} |
| 189 |
|
| 190 |
// what go-json writes for the payload is what encoding/json writes, and what sonic writes with the options |
| 191 |
// of the benchmark. |
| 192 |
func TestTwitterPayload(t *testing.T) { |
| 193 |
for _, v := range []any{twitterGeneric, &twitterBinding} { |
| 194 |
expected, err := stdjson.Marshal(v) |
| 195 |
if err != nil { |
| 196 |
t.Fatal(err) |
| 197 |
} |
| 198 |
got, err := gojson.Marshal(v) |
| 199 |
if err != nil { |
| 200 |
t.Fatal(err) |
| 201 |
} |
| 202 |
if string(got) != string(expected) { |
| 203 |
t.Fatalf("%T: go-json differs from encoding/json", v) |
| 204 |
} |
| 205 |
got, err = sonicTwitter.Marshal(v) |
| 206 |
if err != nil { |
| 207 |
t.Fatal(err) |
| 208 |
} |
| 209 |
if string(got) != string(expected) { |
| 210 |
t.Logf("%T: sonic differs from encoding/json at byte %d", v, firstDifference(got, expected)) |
| 211 |
} |
| 212 |
} |
| 213 |
} |
| 214 |
|
| 215 |
func firstDifference(a, b []byte) int { |
| 216 |
for i := range a { |
| 217 |
if i >= len(b) || a[i] != b[i] { |
| 218 |
return i |
| 219 |
} |
| 220 |
} |
| 221 |
return len(a) |
| 222 |
} |
| 223 |
|
| 224 |
const TwitterJson = `{ |
| 225 |
"statuses": [ |
| 226 |
{ |
| 227 |
"coordinates": null, |
| 228 |
"favorited": false, |
| 229 |
"truncated": false, |
| 230 |
"created_at": "Mon Sep 24 03:35:21 +0000 2012", |
| 231 |
"id_str": "250075927172759552", |
| 232 |
"entities": { |
| 233 |
"urls": [ |
| 234 |
|
| 235 |
], |
| 236 |
"hashtags": [ |
| 237 |
{ |
| 238 |
"text": "freebandnames", |
| 239 |
"indices": [ |
| 240 |
20, |
| 241 |
34 |
| 242 |
] |
| 243 |
} |
| 244 |
], |
| 245 |
"user_mentions": [ |
| 246 |
|
| 247 |
] |
| 248 |
}, |
| 249 |
"in_reply_to_user_id_str": null, |
| 250 |
"contributors": null, |
| 251 |
"text": "Aggressive Ponytail #freebandnames", |
| 252 |
"metadata": { |
| 253 |
"iso_language_code": "en", |
| 254 |
"result_type": "recent" |
| 255 |
}, |
| 256 |
"retweet_count": 0, |
| 257 |
"in_reply_to_status_id_str": null, |
| 258 |
"id": 250075927172759552, |
| 259 |
"geo": null, |
| 260 |
"retweeted": false, |
| 261 |
"in_reply_to_user_id": null, |
| 262 |
"place": null, |
| 263 |
"user": { |
| 264 |
"profile_sidebar_fill_color": "DDEEF6", |
| 265 |
"profile_sidebar_border_color": "C0DEED", |
| 266 |
"profile_background_tile": false, |
| 267 |
"name": "Sean Cummings", |
| 268 |
"profile_image_url": "https://a0.twimg.com/profile_images/2359746665/1v6zfgqo8g0d3mk7ii5s_normal.jpeg", |
| 269 |
"created_at": "Mon Apr 26 06:01:55 +0000 2010", |
| 270 |
"location": "LA, CA", |
| 271 |
"follow_request_sent": null, |
| 272 |
"profile_link_color": "0084B4", |
| 273 |
"is_translator": false, |
| 274 |
"id_str": "137238150", |
| 275 |
"entities": { |
| 276 |
"url": { |
| 277 |
"urls": [ |
| 278 |
{ |
| 279 |
"expanded_url": null, |
| 280 |
"url": "", |
| 281 |
"indices": [ |
| 282 |
0, |
| 283 |
0 |
| 284 |
] |
| 285 |
} |
| 286 |
] |
| 287 |
}, |
| 288 |
"description": { |
| 289 |
"urls": [ |
| 290 |
|
| 291 |
] |
| 292 |
} |
| 293 |
}, |
| 294 |
"default_profile": true, |
| 295 |
"contributors_enabled": false, |
| 296 |
"favourites_count": 0, |
| 297 |
"url": null, |
| 298 |
"profile_image_url_https": "https://si0.twimg.com/profile_images/2359746665/1v6zfgqo8g0d3mk7ii5s_normal.jpeg", |
| 299 |
"utc_offset": -28800, |
| 300 |
"id": 137238150, |
| 301 |
"profile_use_background_image": true, |
| 302 |
"listed_count": 2, |
| 303 |
"profile_text_color": "333333", |
| 304 |
"lang": "en", |
| 305 |
"followers_count": 70, |
| 306 |
"protected": false, |
| 307 |
"notifications": null, |
| 308 |
"profile_background_image_url_https": "https://si0.twimg.com/images/themes/theme1/bg.png", |
| 309 |
"profile_background_color": "C0DEED", |
| 310 |
"verified": false, |
| 311 |
"geo_enabled": true, |
| 312 |
"time_zone": "Pacific Time (US & Canada)", |
| 313 |
"description": "Born 330 Live 310", |
| 314 |
"default_profile_image": false, |
| 315 |
"profile_background_image_url": "https://a0.twimg.com/images/themes/theme1/bg.png", |
| 316 |
"statuses_count": 579, |
| 317 |
"friends_count": 110, |
| 318 |
"following": null, |
| 319 |
"show_all_inline_media": false, |
| 320 |
"screen_name": "sean_cummings" |
| 321 |
}, |
| 322 |
"in_reply_to_screen_name": null, |
| 323 |
"source": "<a href=\"//itunes.apple.com/us/app/twitter/id409789998?mt=12%5C%22\" rel=\"\\\"nofollow\\\"\">Twitter for Mac</a>", |
| 324 |
"in_reply_to_status_id": null |
| 325 |
}, |
| 326 |
{ |
| 327 |
"coordinates": null, |
| 328 |
"favorited": false, |
| 329 |
"truncated": false, |
| 330 |
"created_at": "Fri Sep 21 23:40:54 +0000 2012", |
| 331 |
"id_str": "249292149810667520", |
| 332 |
"entities": { |
| 333 |
"urls": [ |
| 334 |
|
| 335 |
], |
| 336 |
"hashtags": [ |
| 337 |
{ |
| 338 |
"text": "FreeBandNames", |
| 339 |
"indices": [ |
| 340 |
20, |
| 341 |
34 |
| 342 |
] |
| 343 |
} |
| 344 |
], |
| 345 |
"user_mentions": [ |
| 346 |
|
| 347 |
] |
| 348 |
}, |
| 349 |
"in_reply_to_user_id_str": null, |
| 350 |
"contributors": null, |
| 351 |
"text": "Thee Namaste Nerdz. #FreeBandNames", |
| 352 |
"metadata": { |
| 353 |
"iso_language_code": "pl", |
| 354 |
"result_type": "recent" |
| 355 |
}, |
| 356 |
"retweet_count": 0, |
| 357 |
"in_reply_to_status_id_str": null, |
| 358 |
"id": 249292149810667520, |
| 359 |
"geo": null, |
| 360 |
"retweeted": false, |
| 361 |
"in_reply_to_user_id": null, |
| 362 |
"place": null, |
| 363 |
"user": { |
| 364 |
"profile_sidebar_fill_color": "DDFFCC", |
| 365 |
"profile_sidebar_border_color": "BDDCAD", |
| 366 |
"profile_background_tile": true, |
| 367 |
"name": "Chaz Martenstein", |
| 368 |
"profile_image_url": "https://a0.twimg.com/profile_images/447958234/Lichtenstein_normal.jpg", |
| 369 |
"created_at": "Tue Apr 07 19:05:07 +0000 2009", |
| 370 |
"location": "Durham, NC", |
| 371 |
"follow_request_sent": null, |
| 372 |
"profile_link_color": "0084B4", |
| 373 |
"is_translator": false, |
| 374 |
"id_str": "29516238", |
| 375 |
"entities": { |
| 376 |
"url": { |
| 377 |
"urls": [ |
| 378 |
{ |
| 379 |
"expanded_url": null, |
| 380 |
"url": "https://bullcityrecords.com/wnng/", |
| 381 |
"indices": [ |
| 382 |
0, |
| 383 |
32 |
| 384 |
] |
| 385 |
} |
| 386 |
] |
| 387 |
}, |
| 388 |
"description": { |
| 389 |
"urls": [ |
| 390 |
|
| 391 |
] |
| 392 |
} |
| 393 |
}, |
| 394 |
"default_profile": false, |
| 395 |
"contributors_enabled": false, |
| 396 |
"favourites_count": 8, |
| 397 |
"url": "https://bullcityrecords.com/wnng/", |
| 398 |
"profile_image_url_https": "https://si0.twimg.com/profile_images/447958234/Lichtenstein_normal.jpg", |
| 399 |
"utc_offset": -18000, |
| 400 |
"id": 29516238, |
| 401 |
"profile_use_background_image": true, |
| 402 |
"listed_count": 118, |
| 403 |
"profile_text_color": "333333", |
| 404 |
"lang": "en", |
| 405 |
"followers_count": 2052, |
| 406 |
"protected": false, |
| 407 |
"notifications": null, |
| 408 |
"profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/9423277/background_tile.bmp", |
| 409 |
"profile_background_color": "9AE4E8", |
| 410 |
"verified": false, |
| 411 |
"geo_enabled": false, |
| 412 |
"time_zone": "Eastern Time (US & Canada)", |
| 413 |
"description": "You will come to Durham, North Carolina. I will sell you some records then, here in Durham, North Carolina. Fun will happen.", |
| 414 |
"default_profile_image": false, |
| 415 |
"profile_background_image_url": "https://a0.twimg.com/profile_background_images/9423277/background_tile.bmp", |
| 416 |
"statuses_count": 7579, |
| 417 |
"friends_count": 348, |
| 418 |
"following": null, |
| 419 |
"show_all_inline_media": true, |
| 420 |
"screen_name": "bullcityrecords" |
| 421 |
}, |
| 422 |
"in_reply_to_screen_name": null, |
| 423 |
"source": "web", |
| 424 |
"in_reply_to_status_id": null |
| 425 |
}, |
| 426 |
{ |
| 427 |
"coordinates": null, |
| 428 |
"favorited": false, |
| 429 |
"truncated": false, |
| 430 |
"created_at": "Fri Sep 21 23:30:20 +0000 2012", |
| 431 |
"id_str": "249289491129438208", |
| 432 |
"entities": { |
| 433 |
"urls": [ |
| 434 |
|
| 435 |
], |
| 436 |
"hashtags": [ |
| 437 |
{ |
| 438 |
"text": "freebandnames", |
| 439 |
"indices": [ |
| 440 |
29, |
| 441 |
43 |
| 442 |
] |
| 443 |
} |
| 444 |
], |
| 445 |
"user_mentions": [ |
| 446 |
|
| 447 |
] |
| 448 |
}, |
| 449 |
"in_reply_to_user_id_str": null, |
| 450 |
"contributors": null, |
| 451 |
"text": "Mexican Heaven, Mexican Hell #freebandnames", |
| 452 |
"metadata": { |
| 453 |
"iso_language_code": "en", |
| 454 |
"result_type": "recent" |
| 455 |
}, |
| 456 |
"retweet_count": 0, |
| 457 |
"in_reply_to_status_id_str": null, |
| 458 |
"id": 249289491129438208, |
| 459 |
"geo": null, |
| 460 |
"retweeted": false, |
| 461 |
"in_reply_to_user_id": null, |
| 462 |
"place": null, |
| 463 |
"user": { |
| 464 |
"profile_sidebar_fill_color": "99CC33", |
| 465 |
"profile_sidebar_border_color": "829D5E", |
| 466 |
"profile_background_tile": false, |
| 467 |
"name": "Thomas John Wakeman", |
| 468 |
"profile_image_url": "https://a0.twimg.com/profile_images/2219333930/Froggystyle_normal.png", |
| 469 |
"created_at": "Tue Sep 01 21:21:35 +0000 2009", |
| 470 |
"location": "Kingston New York", |
| 471 |
"follow_request_sent": null, |
| 472 |
"profile_link_color": "D02B55", |
| 473 |
"is_translator": false, |
| 474 |
"id_str": "70789458", |
| 475 |
"entities": { |
| 476 |
"url": { |
| 477 |
"urls": [ |
| 478 |
{ |
| 479 |
"expanded_url": null, |
| 480 |
"url": "", |
| 481 |
"indices": [ |
| 482 |
0, |
| 483 |
0 |
| 484 |
] |
| 485 |
} |
| 486 |
] |
| 487 |
}, |
| 488 |
"description": { |
| 489 |
"urls": [ |
| 490 |
|
| 491 |
] |
| 492 |
} |
| 493 |
}, |
| 494 |
"default_profile": false, |
| 495 |
"contributors_enabled": false, |
| 496 |
"favourites_count": 19, |
| 497 |
"url": null, |
| 498 |
"profile_image_url_https": "https://si0.twimg.com/profile_images/2219333930/Froggystyle_normal.png", |
| 499 |
"utc_offset": -18000, |
| 500 |
"id": 70789458, |
| 501 |
"profile_use_background_image": true, |
| 502 |
"listed_count": 1, |
| 503 |
"profile_text_color": "3E4415", |
| 504 |
"lang": "en", |
| 505 |
"followers_count": 63, |
| 506 |
"protected": false, |
| 507 |
"notifications": null, |
| 508 |
"profile_background_image_url_https": "https://si0.twimg.com/images/themes/theme5/bg.gif", |
| 509 |
"profile_background_color": "352726", |
| 510 |
"verified": false, |
| 511 |
"geo_enabled": false, |
| 512 |
"time_zone": "Eastern Time (US & Canada)", |
| 513 |
"description": "Science Fiction Writer, sort of. Likes Superheroes, Mole People, Alt. Timelines.", |
| 514 |
"default_profile_image": false, |
| 515 |
"profile_background_image_url": "https://a0.twimg.com/images/themes/theme5/bg.gif", |
| 516 |
"statuses_count": 1048, |
| 517 |
"friends_count": 63, |
| 518 |
"following": null, |
| 519 |
"show_all_inline_media": false, |
| 520 |
"screen_name": "MonkiesFist" |
| 521 |
}, |
| 522 |
"in_reply_to_screen_name": null, |
| 523 |
"source": "web", |
| 524 |
"in_reply_to_status_id": null |
| 525 |
}, |
| 526 |
{ |
| 527 |
"coordinates": null, |
| 528 |
"favorited": false, |
| 529 |
"truncated": false, |
| 530 |
"created_at": "Fri Sep 21 22:51:18 +0000 2012", |
| 531 |
"id_str": "249279667666817024", |
| 532 |
"entities": { |
| 533 |
"urls": [ |
| 534 |
|
| 535 |
], |
| 536 |
"hashtags": [ |
| 537 |
{ |
| 538 |
"text": "freebandnames", |
| 539 |
"indices": [ |
| 540 |
20, |
| 541 |
34 |
| 542 |
] |
| 543 |
} |
| 544 |
], |
| 545 |
"user_mentions": [ |
| 546 |
|
| 547 |
] |
| 548 |
}, |
| 549 |
"in_reply_to_user_id_str": null, |
| 550 |
"contributors": null, |
| 551 |
"text": "The Foolish Mortals #freebandnames", |
| 552 |
"metadata": { |
| 553 |
"iso_language_code": "en", |
| 554 |
"result_type": "recent" |
| 555 |
}, |
| 556 |
"retweet_count": 0, |
| 557 |
"in_reply_to_status_id_str": null, |
| 558 |
"id": 249279667666817024, |
| 559 |
"geo": null, |
| 560 |
"retweeted": false, |
| 561 |
"in_reply_to_user_id": null, |
| 562 |
"place": null, |
| 563 |
"user": { |
| 564 |
"profile_sidebar_fill_color": "BFAC83", |
| 565 |
"profile_sidebar_border_color": "615A44", |
| 566 |
"profile_background_tile": true, |
| 567 |
"name": "Marty Elmer", |
| 568 |
"profile_image_url": "https://a0.twimg.com/profile_images/1629790393/shrinker_2000_trans_normal.png", |
| 569 |
"created_at": "Mon May 04 00:05:00 +0000 2009", |
| 570 |
"location": "Wisconsin, USA", |
| 571 |
"follow_request_sent": null, |
| 572 |
"profile_link_color": "3B2A26", |
| 573 |
"is_translator": false, |
| 574 |
"id_str": "37539828", |
| 575 |
"entities": { |
| 576 |
"url": { |
| 577 |
"urls": [ |
| 578 |
{ |
| 579 |
"expanded_url": null, |
| 580 |
"url": "https://www.omnitarian.me", |
| 581 |
"indices": [ |
| 582 |
0, |
| 583 |
24 |
| 584 |
] |
| 585 |
} |
| 586 |
] |
| 587 |
}, |
| 588 |
"description": { |
| 589 |
"urls": [ |
| 590 |
|
| 591 |
] |
| 592 |
} |
| 593 |
}, |
| 594 |
"default_profile": false, |
| 595 |
"contributors_enabled": false, |
| 596 |
"favourites_count": 647, |
| 597 |
"url": "https://www.omnitarian.me", |
| 598 |
"profile_image_url_https": "https://si0.twimg.com/profile_images/1629790393/shrinker_2000_trans_normal.png", |
| 599 |
"utc_offset": -21600, |
| 600 |
"id": 37539828, |
| 601 |
"profile_use_background_image": true, |
| 602 |
"listed_count": 52, |
| 603 |
"profile_text_color": "000000", |
| 604 |
"lang": "en", |
| 605 |
"followers_count": 608, |
| 606 |
"protected": false, |
| 607 |
"notifications": null, |
| 608 |
"profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/106455659/rect6056-9.png", |
| 609 |
"profile_background_color": "EEE3C4", |
| 610 |
"verified": false, |
| 611 |
"geo_enabled": false, |
| 612 |
"time_zone": "Central Time (US & Canada)", |
| 613 |
"description": "Cartoonist, Illustrator, and T-Shirt connoisseur", |
| 614 |
"default_profile_image": false, |
| 615 |
"profile_background_image_url": "https://a0.twimg.com/profile_background_images/106455659/rect6056-9.png", |
| 616 |
"statuses_count": 3575, |
| 617 |
"friends_count": 249, |
| 618 |
"following": null, |
| 619 |
"show_all_inline_media": true, |
| 620 |
"screen_name": "Omnitarian" |
| 621 |
}, |
| 622 |
"in_reply_to_screen_name": null, |
| 623 |
"source": "<a href=\"//twitter.com/download/iphone%5C%22\" rel=\"\\\"nofollow\\\"\">Twitter for iPhone</a>", |
| 624 |
"in_reply_to_status_id": null |
| 625 |
} |
| 626 |
], |
| 627 |
"search_metadata": { |
| 628 |
"max_id": 250126199840518145, |
| 629 |
"since_id": 24012619984051000, |
| 630 |
"refresh_url": "?since_id=250126199840518145&q=%23freebandnames&result_type=mixed&include_entities=1", |
| 631 |
"next_results": "?max_id=249279667666817023&q=%23freebandnames&count=4&include_entities=1&result_type=mixed", |
| 632 |
"count": 4, |
| 633 |
"completed_in": 0.035, |
| 634 |
"since_id_str": "24012619984051000", |
| 635 |
"query": "%23freebandnames", |
| 636 |
"max_id_str": "250126199840518145" |
| 637 |
} |
| 638 |
}` |
| 639 |
|
| 640 |
type TwitterStruct struct { |
| 641 |
Statuses []Statuses `json:"statuses"` |
| 642 |
SearchMetadata SearchMetadata `json:"search_metadata"` |
| 643 |
} |
| 644 |
|
| 645 |
type Hashtags struct { |
| 646 |
Text string `json:"text"` |
| 647 |
Indices []int `json:"indices"` |
| 648 |
} |
| 649 |
|
| 650 |
type Entities struct { |
| 651 |
Urls []any `json:"urls"` |
| 652 |
Hashtags []Hashtags `json:"hashtags"` |
| 653 |
UserMentions []any `json:"user_mentions"` |
| 654 |
} |
| 655 |
|
| 656 |
type Metadata struct { |
| 657 |
IsoLanguageCode string `json:"iso_language_code"` |
| 658 |
ResultType string `json:"result_type"` |
| 659 |
} |
| 660 |
|
| 661 |
type Urls struct { |
| 662 |
ExpandedURL any `json:"expanded_url"` |
| 663 |
URL string `json:"url"` |
| 664 |
Indices []int `json:"indices"` |
| 665 |
} |
| 666 |
|
| 667 |
type URL struct { |
| 668 |
Urls []Urls `json:"urls"` |
| 669 |
} |
| 670 |
|
| 671 |
type Description struct { |
| 672 |
Urls []any `json:"urls"` |
| 673 |
} |
| 674 |
|
| 675 |
type UserEntities struct { |
| 676 |
URL URL `json:"url"` |
| 677 |
Description Description `json:"description"` |
| 678 |
} |
| 679 |
|
| 680 |
type User struct { |
| 681 |
ProfileSidebarFillColor string `json:"profile_sidebar_fill_color"` |
| 682 |
ProfileSidebarBorderColor string `json:"profile_sidebar_border_color"` |
| 683 |
ProfileBackgroundTile bool `json:"profile_background_tile"` |
| 684 |
Name string `json:"name"` |
| 685 |
ProfileImageURL string `json:"profile_image_url"` |
| 686 |
CreatedAt string `json:"created_at"` |
| 687 |
Location string `json:"location"` |
| 688 |
FollowRequestSent any `json:"follow_request_sent"` |
| 689 |
ProfileLinkColor string `json:"profile_link_color"` |
| 690 |
IsTranslator bool `json:"is_translator"` |
| 691 |
IDStr string `json:"id_str"` |
| 692 |
Entities UserEntities `json:"entities"` |
| 693 |
DefaultProfile bool `json:"default_profile"` |
| 694 |
ContributorsEnabled bool `json:"contributors_enabled"` |
| 695 |
FavouritesCount int `json:"favourites_count"` |
| 696 |
URL any `json:"url"` |
| 697 |
ProfileImageURLHTTPS string `json:"profile_image_url_https"` |
| 698 |
UtcOffset int `json:"utc_offset"` |
| 699 |
ID int `json:"id"` |
| 700 |
ProfileUseBackgroundImage bool `json:"profile_use_background_image"` |
| 701 |
ListedCount int `json:"listed_count"` |
| 702 |
ProfileTextColor string `json:"profile_text_color"` |
| 703 |
Lang string `json:"lang"` |
| 704 |
FollowersCount int `json:"followers_count"` |
| 705 |
Protected bool `json:"protected"` |
| 706 |
Notifications any `json:"notifications"` |
| 707 |
ProfileBackgroundImageURLHTTPS string `json:"profile_background_image_url_https"` |
| 708 |
ProfileBackgroundColor string `json:"profile_background_color"` |
| 709 |
Verified bool `json:"verified"` |
| 710 |
GeoEnabled bool `json:"geo_enabled"` |
| 711 |
TimeZone string `json:"time_zone"` |
| 712 |
Description string `json:"description"` |
| 713 |
DefaultProfileImage bool `json:"default_profile_image"` |
| 714 |
ProfileBackgroundImageURL string `json:"profile_background_image_url"` |
| 715 |
StatusesCount int `json:"statuses_count"` |
| 716 |
FriendsCount int `json:"friends_count"` |
| 717 |
Following any `json:"following"` |
| 718 |
ShowAllInlineMedia bool `json:"show_all_inline_media"` |
| 719 |
ScreenName string `json:"screen_name"` |
| 720 |
} |
| 721 |
|
| 722 |
type Statuses struct { |
| 723 |
Coordinates any `json:"coordinates"` |
| 724 |
Favorited bool `json:"favorited"` |
| 725 |
Truncated bool `json:"truncated"` |
| 726 |
CreatedAt string `json:"created_at"` |
| 727 |
IDStr string `json:"id_str"` |
| 728 |
Entities Entities `json:"entities"` |
| 729 |
InReplyToUserIDStr any `json:"in_reply_to_user_id_str"` |
| 730 |
Contributors any `json:"contributors"` |
| 731 |
Text string `json:"text"` |
| 732 |
Metadata Metadata `json:"metadata"` |
| 733 |
RetweetCount int `json:"retweet_count"` |
| 734 |
InReplyToStatusIDStr any `json:"in_reply_to_status_id_str"` |
| 735 |
ID int64 `json:"id"` |
| 736 |
Geo any `json:"geo"` |
| 737 |
Retweeted bool `json:"retweeted"` |
| 738 |
InReplyToUserID any `json:"in_reply_to_user_id"` |
| 739 |
Place any `json:"place"` |
| 740 |
User User `json:"user"` |
| 741 |
InReplyToScreenName any `json:"in_reply_to_screen_name"` |
| 742 |
Source string `json:"source"` |
| 743 |
InReplyToStatusID any `json:"in_reply_to_status_id"` |
| 744 |
} |
| 745 |
|
| 746 |
type SearchMetadata struct { |
| 747 |
MaxID int64 `json:"max_id"` |
| 748 |
SinceID int64 `json:"since_id"` |
| 749 |
RefreshURL string `json:"refresh_url"` |
| 750 |
NextResults string `json:"next_results"` |
| 751 |
Count int `json:"count"` |
| 752 |
CompletedIn float64 `json:"completed_in"` |
| 753 |
SinceIDStr string `json:"since_id_str"` |
| 754 |
Query string `json:"query"` |
| 755 |
MaxIDStr string `json:"max_id_str"` |
| 756 |
} |