Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-1190

bson Unmarshal MapEncodeValue can only encode valid map[string]*, but got map[int]interface {}

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None

      type ts struct {
      		Value map[int]string
      	}
      
      	instanceMap := map[string]interface{}{"value": map[int]interface{}{1: 12, 2: 122}}
      	instanceByte, err := bson.Marshal(instanceMap)
      	require.NoError(t, err)
      
      	fmt.Println(fmt.Sprintf("%v", instanceByte))
      	var newInstance ts
      	err = bson.Unmarshal(instanceByte, &newInstance)
      	require.NoError(t, err)
      

            Assignee:
            isabella.siu@mongodb.com Isabella Siu (Inactive)
            Reporter:
            reage521@gmail.com Tiansheng Ren
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: