Debian Codegraph @

internal/jsontest/testdata.go

raw symbols SCIP
1 // Copyright 2020 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 //go:build !goexperiment.jsonv2 || !go1.25
6
7 // Package jsontest contains functionality to assist in testing JSON.
8 package jsontest
9
10 import (
11 "bytes"
12 "embed"
13 "errors"
14 "io"
15 "io/fs"
16 "path"
17 "slices"
18 "strings"
19 "sync"
20 "time"
21
22 "github.com/go-json-experiment/json/internal/zstd"
23 )
24
25 // Embed the testdata directory as a fs.FS because this package is imported
26 // by other packages such that the location of testdata may change relative
27 // to the working directory of the test itself.
28 //
29 //go:embed testdata/*.json.zst
30 var testdataFS embed.FS
31
32 type Entry struct {
33 Name string
34 Data func() []byte
35 New func() any // nil if there is no concrete type for this
36 }
37
38 func mustGet[T any](v T, err error) T {
39 if err != nil {
40 panic(err)
41 }
42 return v
43 }
44
45 // Data is a list of JSON testdata.
46 var Data = func() (entries []Entry) {
47 fis := mustGet(fs.ReadDir(testdataFS, "testdata"))
48 slices.SortFunc(fis, func(x, y fs.DirEntry) int { return strings.Compare(x.Name(), y.Name()) })
49 for _, fi := range fis {
50 var entry Entry
51
52 // Convert snake_case file name to CamelCase.
53 words := strings.Split(strings.TrimSuffix(fi.Name(), ".json.zst"), "_")
54 for i := range words {
55 words[i] = strings.Title(words[i])
56 }
57 entry.Name = strings.Join(words, "")
58
59 // Lazily read and decompress the test data.
60 entry.Data = sync.OnceValue(func() []byte {
61 filePath := path.Join("testdata", fi.Name())
62 b := mustGet(fs.ReadFile(testdataFS, filePath))
63 zr := zstd.NewReader(bytes.NewReader(b))
64 return mustGet(io.ReadAll(zr))
65 })
66
67 // Check whether there is a concrete type for this data.
68 switch entry.Name {
69 case "CanadaGeometry":
70 entry.New = func() any { return new(canadaRoot) }
71 case "CitmCatalog":
72 entry.New = func() any { return new(citmRoot) }
73 case "GolangSource":
74 entry.New = func() any { return new(golangRoot) }
75 case "StringEscaped":
76 entry.New = func() any { return new(stringRoot) }
77 case "StringUnicode":
78 entry.New = func() any { return new(stringRoot) }
79 case "SyntheaFhir":
80 entry.New = func() any { return new(syntheaRoot) }
81 case "TwitterStatus":
82 entry.New = func() any { return new(twitterRoot) }
83 }
84
85 entries = append(entries, entry)
86 }
87 return entries
88 }()
89
90 type (
91 canadaRoot struct {
92 Type string `json:"type"`
93 Features []struct {
94 Type string `json:"type"`
95 Properties struct {
96 Name string `json:"name"`
97 } `json:"properties"`
98 Geometry struct {
99 Type string `json:"type"`
100 Coordinates [][][2]float64 `json:"coordinates"`
101 } `json:"geometry"`
102 } `json:"features"`
103 }
104 )
105
106 type (
107 citmRoot struct {
108 AreaNames map[int64]string `json:"areaNames"`
109 AudienceSubCategoryNames map[int64]string `json:"audienceSubCategoryNames"`
110 BlockNames map[int64]string `json:"blockNames"`
111 Events map[int64]struct {
112 Description string `json:"description"`
113 ID int `json:"id"`
114 Logo string `json:"logo"`
115 Name string `json:"name"`
116 SubTopicIds []int `json:"subTopicIds"`
117 SubjectCode any `json:"subjectCode"`
118 Subtitle any `json:"subtitle"`
119 TopicIds []int `json:"topicIds"`
120 } `json:"events"`
121 Performances []struct {
122 EventID int `json:"eventId"`
123 ID int `json:"id"`
124 Logo any `json:"logo"`
125 Name any `json:"name"`
126 Prices []struct {
127 Amount int `json:"amount"`
128 AudienceSubCategoryID int64 `json:"audienceSubCategoryId"`
129 SeatCategoryID int64 `json:"seatCategoryId"`
130 } `json:"prices"`
131 SeatCategories []struct {
132 Areas []struct {
133 AreaID int `json:"areaId"`
134 BlockIds []any `json:"blockIds"`
135 } `json:"areas"`
136 SeatCategoryID int `json:"seatCategoryId"`
137 } `json:"seatCategories"`
138 SeatMapImage any `json:"seatMapImage"`
139 Start int64 `json:"start"`
140 VenueCode string `json:"venueCode"`
141 } `json:"performances"`
142 SeatCategoryNames map[uint64]string `json:"seatCategoryNames"`
143 SubTopicNames map[uint64]string `json:"subTopicNames"`
144 SubjectNames map[uint64]string `json:"subjectNames"`
145 TopicNames map[uint64]string `json:"topicNames"`
146 TopicSubTopics map[uint64][]uint64 `json:"topicSubTopics"`
147 VenueNames map[string]string `json:"venueNames"`
148 }
149 )
150
151 type (
152 golangRoot struct {
153 Tree *golangNode `json:"tree"`
154 Username string `json:"username"`
155 }
156 golangNode struct {
157 Name string `json:"name"`
158 Kids []golangNode `json:"kids"`
159 CLWeight float64 `json:"cl_weight"`
160 Touches int `json:"touches"`
161 MinT uint64 `json:"min_t"`
162 MaxT uint64 `json:"max_t"`
163 MeanT uint64 `json:"mean_t"`
164 }
165 )
166
167 type (
168 stringRoot struct {
169 Arabic string `json:"Arabic"`
170 ArabicPresentationFormsA string `json:"Arabic Presentation Forms-A"`
171 ArabicPresentationFormsB string `json:"Arabic Presentation Forms-B"`
172 Armenian string `json:"Armenian"`
173 Arrows string `json:"Arrows"`
174 Bengali string `json:"Bengali"`
175 Bopomofo string `json:"Bopomofo"`
176 BoxDrawing string `json:"Box Drawing"`
177 CJKCompatibility string `json:"CJK Compatibility"`
178 CJKCompatibilityForms string `json:"CJK Compatibility Forms"`
179 CJKCompatibilityIdeographs string `json:"CJK Compatibility Ideographs"`
180 CJKSymbolsAndPunctuation string `json:"CJK Symbols and Punctuation"`
181 CJKUnifiedIdeographs string `json:"CJK Unified Ideographs"`
182 CJKUnifiedIdeographsExtensionA string `json:"CJK Unified Ideographs Extension A"`
183 CJKUnifiedIdeographsExtensionB string `json:"CJK Unified Ideographs Extension B"`
184 Cherokee string `json:"Cherokee"`
185 CurrencySymbols string `json:"Currency Symbols"`
186 Cyrillic string `json:"Cyrillic"`
187 CyrillicSupplementary string `json:"Cyrillic Supplementary"`
188 Devanagari string `json:"Devanagari"`
189 EnclosedAlphanumerics string `json:"Enclosed Alphanumerics"`
190 EnclosedCJKLettersAndMonths string `json:"Enclosed CJK Letters and Months"`
191 Ethiopic string `json:"Ethiopic"`
192 GeometricShapes string `json:"Geometric Shapes"`
193 Georgian string `json:"Georgian"`
194 GreekAndCoptic string `json:"Greek and Coptic"`
195 Gujarati string `json:"Gujarati"`
196 Gurmukhi string `json:"Gurmukhi"`
197 HangulCompatibilityJamo string `json:"Hangul Compatibility Jamo"`
198 HangulJamo string `json:"Hangul Jamo"`
199 HangulSyllables string `json:"Hangul Syllables"`
200 Hebrew string `json:"Hebrew"`
201 Hiragana string `json:"Hiragana"`
202 IPAExtentions string `json:"IPA Extentions"`
203 KangxiRadicals string `json:"Kangxi Radicals"`
204 Katakana string `json:"Katakana"`
205 Khmer string `json:"Khmer"`
206 KhmerSymbols string `json:"Khmer Symbols"`
207 Latin string `json:"Latin"`
208 LatinExtendedAdditional string `json:"Latin Extended Additional"`
209 Latin1Supplement string `json:"Latin-1 Supplement"`
210 LatinExtendedA string `json:"Latin-Extended A"`
211 LatinExtendedB string `json:"Latin-Extended B"`
212 LetterlikeSymbols string `json:"Letterlike Symbols"`
213 Malayalam string `json:"Malayalam"`
214 MathematicalAlphanumericSymbols string `json:"Mathematical Alphanumeric Symbols"`
215 MathematicalOperators string `json:"Mathematical Operators"`
216 MiscellaneousSymbols string `json:"Miscellaneous Symbols"`
217 Mongolian string `json:"Mongolian"`
218 NumberForms string `json:"Number Forms"`
219 Oriya string `json:"Oriya"`
220 PhoneticExtensions string `json:"Phonetic Extensions"`
221 SupplementalArrowsB string `json:"Supplemental Arrows-B"`
222 Syriac string `json:"Syriac"`
223 Tamil string `json:"Tamil"`
224 Thaana string `json:"Thaana"`
225 Thai string `json:"Thai"`
226 UnifiedCanadianAboriginalSyllabics string `json:"Unified Canadian Aboriginal Syllabics"`
227 YiRadicals string `json:"Yi Radicals"`
228 YiSyllables string `json:"Yi Syllables"`
229 }
230 )
231
232 type (
233 syntheaRoot struct {
234 Entry []struct {
235 FullURL string `json:"fullUrl"`
236 Request *struct {
237 Method string `json:"method"`
238 URL string `json:"url"`
239 } `json:"request"`
240 Resource *struct {
241 AbatementDateTime time.Time `json:"abatementDateTime"`
242 AchievementStatus syntheaCode `json:"achievementStatus"`
243 Active bool `json:"active"`
244 Activity []struct {
245 Detail *struct {
246 Code syntheaCode `json:"code"`
247 Location syntheaReference `json:"location"`
248 Status string `json:"status"`
249 } `json:"detail"`
250 } `json:"activity"`
251 Address []syntheaAddress `json:"address"`
252 Addresses []syntheaReference `json:"addresses"`
253 AuthoredOn time.Time `json:"authoredOn"`
254 BillablePeriod syntheaRange `json:"billablePeriod"`
255 BirthDate string `json:"birthDate"`
256 CareTeam []struct {
257 Provider syntheaReference `json:"provider"`
258 Reference string `json:"reference"`
259 Role syntheaCode `json:"role"`
260 Sequence int64 `json:"sequence"`
261 } `json:"careTeam"`
262 Category []syntheaCode `json:"category"`
263 Claim syntheaReference `json:"claim"`
264 Class syntheaCoding `json:"class"`
265 ClinicalStatus syntheaCode `json:"clinicalStatus"`
266 Code syntheaCode `json:"code"`
267 Communication []struct {
268 Language syntheaCode `json:"language"`
269 } `json:"communication"`
270 Component []struct {
271 Code syntheaCode `json:"code"`
272 ValueQuantity syntheaCoding `json:"valueQuantity"`
273 } `json:"component"`
274 Contained []struct {
275 Beneficiary syntheaReference `json:"beneficiary"`
276 ID string `json:"id"`
277 Intent string `json:"intent"`
278 Payor []syntheaReference `json:"payor"`
279 Performer []syntheaReference `json:"performer"`
280 Requester syntheaReference `json:"requester"`
281 ResourceType string `json:"resourceType"`
282 Status string `json:"status"`
283 Subject syntheaReference `json:"subject"`
284 Type syntheaCode `json:"type"`
285 } `json:"contained"`
286 Created time.Time `json:"created"`
287 DeceasedDateTime time.Time `json:"deceasedDateTime"`
288 Description syntheaCode `json:"description"`
289 Diagnosis []struct {
290 DiagnosisReference syntheaReference `json:"diagnosisReference"`
291 Sequence int64 `json:"sequence"`
292 Type []syntheaCode `json:"type"`
293 } `json:"diagnosis"`
294 DosageInstruction []struct {
295 AsNeededBoolean bool `json:"asNeededBoolean"`
296 DoseAndRate []struct {
297 DoseQuantity *struct {
298 Value float64 `json:"value"`
299 } `json:"doseQuantity"`
300 Type syntheaCode `json:"type"`
301 } `json:"doseAndRate"`
302 Sequence int64 `json:"sequence"`
303 Timing *struct {
304 Repeat *struct {
305 Frequency int64 `json:"frequency"`
306 Period float64 `json:"period"`
307 PeriodUnit string `json:"periodUnit"`
308 } `json:"repeat"`
309 } `json:"timing"`
310 } `json:"dosageInstruction"`
311 EffectiveDateTime time.Time `json:"effectiveDateTime"`
312 Encounter syntheaReference `json:"encounter"`
313 Extension []syntheaExtension `json:"extension"`
314 Gender string `json:"gender"`
315 Goal []syntheaReference `json:"goal"`
316 ID string `json:"id"`
317 Identifier []struct {
318 System string `json:"system"`
319 Type syntheaCode `json:"type"`
320 Use string `json:"use"`
321 Value string `json:"value"`
322 } `json:"identifier"`
323 Insurance []struct {
324 Coverage syntheaReference `json:"coverage"`
325 Focal bool `json:"focal"`
326 Sequence int64 `json:"sequence"`
327 } `json:"insurance"`
328 Insurer syntheaReference `json:"insurer"`
329 Intent string `json:"intent"`
330 Issued time.Time `json:"issued"`
331 Item []struct {
332 Adjudication []struct {
333 Amount syntheaCurrency `json:"amount"`
334 Category syntheaCode `json:"category"`
335 } `json:"adjudication"`
336 Category syntheaCode `json:"category"`
337 DiagnosisSequence []int64 `json:"diagnosisSequence"`
338 Encounter []syntheaReference `json:"encounter"`
339 InformationSequence []int64 `json:"informationSequence"`
340 LocationCodeableConcept syntheaCode `json:"locationCodeableConcept"`
341 Net syntheaCurrency `json:"net"`
342 ProcedureSequence []int64 `json:"procedureSequence"`
343 ProductOrService syntheaCode `json:"productOrService"`
344 Sequence int64 `json:"sequence"`
345 ServicedPeriod syntheaRange `json:"servicedPeriod"`
346 } `json:"item"`
347 LifecycleStatus string `json:"lifecycleStatus"`
348 ManagingOrganization []syntheaReference `json:"managingOrganization"`
349 MaritalStatus syntheaCode `json:"maritalStatus"`
350 MedicationCodeableConcept syntheaCode `json:"medicationCodeableConcept"`
351 MultipleBirthBoolean bool `json:"multipleBirthBoolean"`
352 Name rawValue `json:"name"`
353 NumberOfInstances int64 `json:"numberOfInstances"`
354 NumberOfSeries int64 `json:"numberOfSeries"`
355 OccurrenceDateTime time.Time `json:"occurrenceDateTime"`
356 OnsetDateTime time.Time `json:"onsetDateTime"`
357 Outcome string `json:"outcome"`
358 Participant []struct {
359 Individual syntheaReference `json:"individual"`
360 Member syntheaReference `json:"member"`
361 Role []syntheaCode `json:"role"`
362 } `json:"participant"`
363 Patient syntheaReference `json:"patient"`
364 Payment *struct {
365 Amount syntheaCurrency `json:"amount"`
366 } `json:"payment"`
367 PerformedPeriod syntheaRange `json:"performedPeriod"`
368 Period syntheaRange `json:"period"`
369 Prescription syntheaReference `json:"prescription"`
370 PrimarySource bool `json:"primarySource"`
371 Priority syntheaCode `json:"priority"`
372 Procedure []struct {
373 ProcedureReference syntheaReference `json:"procedureReference"`
374 Sequence int64 `json:"sequence"`
375 } `json:"procedure"`
376 Provider syntheaReference `json:"provider"`
377 ReasonCode []syntheaCode `json:"reasonCode"`
378 ReasonReference []syntheaReference `json:"reasonReference"`
379 RecordedDate time.Time `json:"recordedDate"`
380 Referral syntheaReference `json:"referral"`
381 Requester syntheaReference `json:"requester"`
382 ResourceType string `json:"resourceType"`
383 Result []syntheaReference `json:"result"`
384 Series []struct {
385 BodySite syntheaCoding `json:"bodySite"`
386 Instance []struct {
387 Number int64 `json:"number"`
388 SopClass syntheaCoding `json:"sopClass"`
389 Title string `json:"title"`
390 UID string `json:"uid"`
391 } `json:"instance"`
392 Modality syntheaCoding `json:"modality"`
393 Number int64 `json:"number"`
394 NumberOfInstances int64 `json:"numberOfInstances"`
395 Started string `json:"started"`
396 UID string `json:"uid"`
397 } `json:"series"`
398 ServiceProvider syntheaReference `json:"serviceProvider"`
399 Started time.Time `json:"started"`
400 Status string `json:"status"`
401 Subject syntheaReference `json:"subject"`
402 SupportingInfo []struct {
403 Category syntheaCode `json:"category"`
404 Sequence int64 `json:"sequence"`
405 ValueReference syntheaReference `json:"valueReference"`
406 } `json:"supportingInfo"`
407 Telecom []map[string]string `json:"telecom"`
408 Text map[string]string `json:"text"`
409 Total rawValue `json:"total"`
410 Type rawValue `json:"type"`
411 Use string `json:"use"`
412 VaccineCode syntheaCode `json:"vaccineCode"`
413 ValueCodeableConcept syntheaCode `json:"valueCodeableConcept"`
414 ValueQuantity syntheaCoding `json:"valueQuantity"`
415 VerificationStatus syntheaCode `json:"verificationStatus"`
416 } `json:"resource"`
417 } `json:"entry"`
418 ResourceType string `json:"resourceType"`
419 Type string `json:"type"`
420 }
421 syntheaCode struct {
422 Coding []syntheaCoding `json:"coding"`
423 Text string `json:"text"`
424 }
425 syntheaCoding struct {
426 Code string `json:"code"`
427 Display string `json:"display"`
428 System string `json:"system"`
429 Unit string `json:"unit"`
430 Value float64 `json:"value"`
431 }
432 syntheaReference struct {
433 Display string `json:"display"`
434 Reference string `json:"reference"`
435 }
436 syntheaAddress struct {
437 City string `json:"city"`
438 Country string `json:"country"`
439 Extension []syntheaExtension `json:"extension"`
440 Line []string `json:"line"`
441 PostalCode string `json:"postalCode"`
442 State string `json:"state"`
443 }
444 syntheaExtension struct {
445 URL string `json:"url"`
446 ValueAddress syntheaAddress `json:"valueAddress"`
447 ValueCode string `json:"valueCode"`
448 ValueDecimal float64 `json:"valueDecimal"`
449 ValueString string `json:"valueString"`
450 Extension []syntheaExtension `json:"extension"`
451 }
452 syntheaRange struct {
453 End time.Time `json:"end"`
454 Start time.Time `json:"start"`
455 }
456 syntheaCurrency struct {
457 Currency string `json:"currency"`
458 Value float64 `json:"value"`
459 }
460 )
461
462 type (
463 twitterRoot struct {
464 Statuses []twitterStatus `json:"statuses"`
465 SearchMetadata struct {
466 CompletedIn float64 `json:"completed_in"`
467 MaxID int64 `json:"max_id"`
468 MaxIDStr int64 `json:"max_id_str,string"`
469 NextResults string `json:"next_results"`
470 Query string `json:"query"`
471 RefreshURL string `json:"refresh_url"`
472 Count int `json:"count"`
473 SinceID int `json:"since_id"`
474 SinceIDStr int `json:"since_id_str,string"`
475 } `json:"search_metadata"`
476 }
477 twitterStatus struct {
478 Metadata struct {
479 ResultType string `json:"result_type"`
480 IsoLanguageCode string `json:"iso_language_code"`
481 } `json:"metadata"`
482 CreatedAt string `json:"created_at"`
483 ID int64 `json:"id"`
484 IDStr int64 `json:"id_str,string"`
485 Text string `json:"text"`
486 Source string `json:"source"`
487 Truncated bool `json:"truncated"`
488 InReplyToStatusID int64 `json:"in_reply_to_status_id"`
489 InReplyToStatusIDStr int64 `json:"in_reply_to_status_id_str,string"`
490 InReplyToUserID int64 `json:"in_reply_to_user_id"`
491 InReplyToUserIDStr int64 `json:"in_reply_to_user_id_str,string"`
492 InReplyToScreenName string `json:"in_reply_to_screen_name"`
493 User twitterUser `json:"user,omitempty"`
494 Geo any `json:"geo"`
495 Coordinates any `json:"coordinates"`
496 Place any `json:"place"`
497 Contributors any `json:"contributors"`
498 RetweeetedStatus *twitterStatus `json:"retweeted_status"`
499 RetweetCount int `json:"retweet_count"`
500 FavoriteCount int `json:"favorite_count"`
501 Entities twitterEntities `json:"entities,omitempty"`
502 Favorited bool `json:"favorited"`
503 Retweeted bool `json:"retweeted"`
504 PossiblySensitive bool `json:"possibly_sensitive"`
505 Lang string `json:"lang"`
506 }
507 twitterUser struct {
508 ID int64 `json:"id"`
509 IDStr string `json:"id_str"`
510 Name string `json:"name"`
511 ScreenName string `json:"screen_name"`
512 Location string `json:"location"`
513 Description string `json:"description"`
514 URL any `json:"url"`
515 Entities twitterEntities `json:"entities"`
516 Protected bool `json:"protected"`
517 FollowersCount int `json:"followers_count"`
518 FriendsCount int `json:"friends_count"`
519 ListedCount int `json:"listed_count"`
520 CreatedAt string `json:"created_at"`
521 FavouritesCount int `json:"favourites_count"`
522 UtcOffset int `json:"utc_offset"`
523 TimeZone string `json:"time_zone"`
524 GeoEnabled bool `json:"geo_enabled"`
525 Verified bool `json:"verified"`
526 StatusesCount int `json:"statuses_count"`
527 Lang string `json:"lang"`
528 ContributorsEnabled bool `json:"contributors_enabled"`
529 IsTranslator bool `json:"is_translator"`
530 IsTranslationEnabled bool `json:"is_translation_enabled"`
531 ProfileBackgroundColor string `json:"profile_background_color"`
532 ProfileBackgroundImageURL string `json:"profile_background_image_url"`
533 ProfileBackgroundImageURLHTTPS string `json:"profile_background_image_url_https"`
534 ProfileBackgroundTile bool `json:"profile_background_tile"`
535 ProfileImageURL string `json:"profile_image_url"`
536 ProfileImageURLHTTPS string `json:"profile_image_url_https"`
537 ProfileBannerURL string `json:"profile_banner_url"`
538 ProfileLinkColor string `json:"profile_link_color"`
539 ProfileSidebarBorderColor string `json:"profile_sidebar_border_color"`
540 ProfileSidebarFillColor string `json:"profile_sidebar_fill_color"`
541 ProfileTextColor string `json:"profile_text_color"`
542 ProfileUseBackgroundImage bool `json:"profile_use_background_image"`
543 DefaultProfile bool `json:"default_profile"`
544 DefaultProfileImage bool `json:"default_profile_image"`
545 Following bool `json:"following"`
546 FollowRequestSent bool `json:"follow_request_sent"`
547 Notifications bool `json:"notifications"`
548 }
549 twitterEntities struct {
550 Hashtags []any `json:"hashtags"`
551 Symbols []any `json:"symbols"`
552 URL *twitterURL `json:"url"`
553 URLs []twitterURL `json:"urls"`
554 UserMentions []struct {
555 ScreenName string `json:"screen_name"`
556 Name string `json:"name"`
557 ID int64 `json:"id"`
558 IDStr int64 `json:"id_str,string"`
559 Indices []int `json:"indices"`
560 } `json:"user_mentions"`
561 Description struct {
562 URLs []twitterURL `json:"urls"`
563 } `json:"description"`
564 Media []struct {
565 ID int64 `json:"id"`
566 IDStr string `json:"id_str"`
567 Indices []int `json:"indices"`
568 MediaURL string `json:"media_url"`
569 MediaURLHTTPS string `json:"media_url_https"`
570 URL string `json:"url"`
571 DisplayURL string `json:"display_url"`
572 ExpandedURL string `json:"expanded_url"`
573 Type string `json:"type"`
574 Sizes map[string]struct {
575 W int `json:"w"`
576 H int `json:"h"`
577 Resize string `json:"resize"`
578 } `json:"sizes"`
579 SourceStatusID int64 `json:"source_status_id"`
580 SourceStatusIDStr int64 `json:"source_status_id_str,string"`
581 } `json:"media"`
582 }
583 twitterURL struct {
584 URL string `json:"url"`
585 URLs []twitterURL `json:"urls"`
586 ExpandedURL string `json:"expanded_url"`
587 DisplayURL string `json:"display_url"`
588 Indices []int `json:"indices"`
589 }
590 )
591
592 // rawValue is the raw encoded JSON value.
593 type rawValue []byte
594
595 func (v rawValue) MarshalJSON() ([]byte, error) {
596 if v == nil {
597 return []byte("null"), nil
598 }
599 return v, nil
600 }
601
602 func (v *rawValue) UnmarshalJSON(b []byte) error {
603 if v == nil {
604 return errors.New("jsontest.rawValue: UnmarshalJSON on nil pointer")
605 }
606 *v = append((*v)[:0], b...)
607 return nil
608 }