Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConcurrentMap 内容无法转换成 JSON 字符串 #6

Open
custa opened this issue Oct 28, 2016 · 1 comment
Open

ConcurrentMap 内容无法转换成 JSON 字符串 #6

custa opened this issue Oct 28, 2016 · 1 comment

Comments

@custa
Copy link

custa commented Oct 28, 2016

package map1

import (
    "testing"
    "reflect"
    "fmt"
    "encoding/json"
)

func Test2JSON(t *testing.T){
    cmap := NewConcurrentMap(reflect.TypeOf(string("")), reflect.TypeOf(string("")))
    cmap.Put("k1", "v1")
    fmt.Printf("%v\n", cmap)

    bytes, err := json.Marshal(cmap) // 无法将内部数据转成 JSON
    if err == nil {
        fmt.Println(string(bytes))
    }else {
        fmt.Printf("err = %v\n",err)
    }
}

C:/Go\bin\go.exe test -v basic/map1 -run ^Test2JSON$
ConcurrentMap<string,string>{k1:v1}
{}
ok basic/map1 0.234s

@zuoRambo
Copy link

zuoRambo commented Feb 6, 2017

需要修改String方法 原版是为了友好打印的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants