Skip to content

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

@custa

Description

@custa
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions