@@ -52,7 +52,7 @@ const (
5252}`
5353)
5454
55- var testDocumentJSON interface {}
55+ var testDocumentJSON any
5656
5757type testStructJSON struct {
5858 Foo []string `json:"foo"`
@@ -67,7 +67,7 @@ type testStructJSON struct {
6767 } `json:"obj"`
6868}
6969
70- type aliasedMap map [string ]interface {}
70+ type aliasedMap map [string ]any
7171
7272var testStructJSONDoc testStructJSON
7373var testStructJSONPtr * testStructJSON
@@ -109,7 +109,7 @@ func TestFullDocument(t *testing.T) {
109109 t .Errorf ("Get(%v) error %v" , in , err .Error ())
110110 }
111111
112- if len (result .(map [string ]interface {} )) != TestDocumentNBItems {
112+ if len (result .(map [string ]any )) != TestDocumentNBItems {
113113 t .Errorf ("Get(%v) = %v, expect full document" , in , result )
114114 }
115115
@@ -118,7 +118,7 @@ func TestFullDocument(t *testing.T) {
118118 t .Errorf ("Get(%v) error %v" , in , err .Error ())
119119 }
120120
121- if len (result .(map [string ]interface {} )) != TestDocumentNBItems {
121+ if len (result .(map [string ]any )) != TestDocumentNBItems {
122122 t .Errorf ("Get(%v) = %v, expect full document" , in , result )
123123 }
124124}
@@ -160,7 +160,7 @@ type pointableImpl struct {
160160 a string
161161}
162162
163- func (p pointableImpl ) JSONLookup (token string ) (interface {} , error ) {
163+ func (p pointableImpl ) JSONLookup (token string ) (any , error ) {
164164 if token == "some" {
165165 return p .a , nil
166166 }
@@ -169,7 +169,7 @@ func (p pointableImpl) JSONLookup(token string) (interface{}, error) {
169169
170170type pointableMap map [string ]string
171171
172- func (p pointableMap ) JSONLookup (token string ) (interface {} , error ) {
172+ func (p pointableMap ) JSONLookup (token string ) (any , error ) {
173173 if token == "swap" {
174174 return p ["swapped" ], nil
175175 }
@@ -213,7 +213,7 @@ func TestGetNode(t *testing.T) {
213213 assert .NoError (t , err )
214214 assert .Len (t , result , TestNodeObjNBItems )
215215
216- result , _ , err = p .Get (aliasedMap (testDocumentJSON .(map [string ]interface {} )))
216+ result , _ , err = p .Get (aliasedMap (testDocumentJSON .(map [string ]any )))
217217 assert .NoError (t , err )
218218 assert .Len (t , result , TestNodeObjNBItems )
219219
@@ -288,8 +288,8 @@ func TestOtherThings(t *testing.T) {
288288 p , err = New ("/foo/1" )
289289 assert .NoError (t , err )
290290 expected := "hello"
291- bbb := testDocumentJSON .(map [string ]interface {} )["foo" ]
292- bbb .([]interface {} )[1 ] = "hello"
291+ bbb := testDocumentJSON .(map [string ]any )["foo" ]
292+ bbb .([]any )[1 ] = "hello"
293293
294294 v , _ , err := p .Get (testDocumentJSON )
295295 assert .NoError (t , err )
@@ -371,7 +371,7 @@ func (s *settableDoc) UnmarshalJSON(data []byte) error {
371371}
372372
373373// JSONLookup implements an interface to customize json pointer lookup
374- func (s settableDoc ) JSONLookup (token string ) (interface {} , error ) {
374+ func (s settableDoc ) JSONLookup (token string ) (any , error ) {
375375 switch token {
376376 case "a" :
377377 return & s .Coll , nil
@@ -383,7 +383,7 @@ func (s settableDoc) JSONLookup(token string) (interface{}, error) {
383383}
384384
385385// JSONLookup implements an interface to customize json pointer lookup
386- func (s * settableDoc ) JSONSet (token string , data interface {} ) error {
386+ func (s * settableDoc ) JSONSet (token string , data any ) error {
387387 switch token {
388388 case "a" :
389389 switch dt := data .(type ) {
@@ -440,15 +440,15 @@ func (s *settableColl) UnmarshalJSON(data []byte) error {
440440}
441441
442442// JSONLookup implements an interface to customize json pointer lookup
443- func (s settableColl ) JSONLookup (token string ) (interface {} , error ) {
443+ func (s settableColl ) JSONLookup (token string ) (any , error ) {
444444 if tok , err := strconv .Atoi (token ); err == nil {
445445 return & s .Items [tok ], nil
446446 }
447447 return nil , fmt .Errorf ("%s is not a valid index" , token )
448448}
449449
450450// JSONLookup implements an interface to customize json pointer lookup
451- func (s * settableColl ) JSONSet (token string , data interface {} ) error {
451+ func (s * settableColl ) JSONSet (token string , data any ) error {
452452 if _ , err := strconv .Atoi (token ); err == nil {
453453 _ , err := SetForToken (s .Items , token , data )
454454 return err
@@ -476,7 +476,7 @@ func TestSetNode(t *testing.T) {
476476
477477 jsonText := `{"a":[{"b": 1, "c": 2}], "d": 3}`
478478
479- var jsonDocument interface {}
479+ var jsonDocument any
480480 if assert .NoError (t , json .Unmarshal ([]byte (jsonText ), & jsonDocument )) {
481481 in := "/a/0/c"
482482 p , err := New (in )
@@ -485,13 +485,13 @@ func TestSetNode(t *testing.T) {
485485 _ , err = p .Set (jsonDocument , 999 )
486486 assert .NoError (t , err )
487487
488- firstNode := jsonDocument .(map [string ]interface {} )
488+ firstNode := jsonDocument .(map [string ]any )
489489 assert .Len (t , firstNode , 2 )
490490
491- sliceNode := firstNode ["a" ].([]interface {} )
491+ sliceNode := firstNode ["a" ].([]any )
492492 assert .Len (t , sliceNode , 1 )
493493
494- changedNode := sliceNode [0 ].(map [string ]interface {} )
494+ changedNode := sliceNode [0 ].(map [string ]any )
495495 chNodeVI := changedNode ["c" ]
496496 if assert .IsType (t , 0 , chNodeVI ) {
497497 changedNodeValue := chNodeVI .(int )
@@ -503,14 +503,14 @@ func TestSetNode(t *testing.T) {
503503
504504 v , err := New ("/a/0" )
505505 if assert .NoError (t , err ) {
506- _ , err = v .Set (jsonDocument , map [string ]interface {} {"b" : 3 , "c" : 8 })
506+ _ , err = v .Set (jsonDocument , map [string ]any {"b" : 3 , "c" : 8 })
507507 if assert .NoError (t , err ) {
508- firstNode := jsonDocument .(map [string ]interface {} )
508+ firstNode := jsonDocument .(map [string ]any )
509509 assert .Len (t , firstNode , 2 )
510510
511- sliceNode := firstNode ["a" ].([]interface {} )
511+ sliceNode := firstNode ["a" ].([]any )
512512 assert .Len (t , sliceNode , 1 )
513- changedNode := sliceNode [0 ].(map [string ]interface {} )
513+ changedNode := sliceNode [0 ].(map [string ]any )
514514 assert .Equal (t , 3 , changedNode ["b" ])
515515 assert .Equal (t , 8 , changedNode ["c" ])
516516 }
0 commit comments