github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/utils/json/marshal_test.go (about) 1 package json_test 2 3 import ( 4 "testing" 5 6 "github.com/lmorg/murex/test/count" 7 "github.com/lmorg/murex/utils/json" 8 ) 9 10 // TestJsonMap tests the the JSON wrapper can marshal interface{} maps which the 11 // core library cannot 12 func TestJsonMap(t *testing.T) { 13 count.Tests(t, 1) 14 15 obj := make(map[interface{}]interface{}) 16 obj["a"] = "b" 17 obj[1] = 2 18 19 b, err := json.Marshal(obj, false) 20 if err != nil { 21 t.Error("Error marshalling: " + err.Error()) 22 } 23 24 if string(b) != `{"a":"b","1":2}` && string(b) != `{"1":2,"a":"b"}` { 25 t.Error("Unexpected JSON returned: " + string(b)) 26 } 27 }