[GODRIVER-1756] cannot decode array into a map[string]* Created: 27/Sep/20 Updated: 27/Oct/23 Resolved: 02/Nov/20 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | BSON |
| Affects Version/s: | 1.4.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | 滨 黄 | Assignee: | Isabella Siu (Inactive) |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Description |
|
I am trying to read a K/V into map[string]string, but it reports "cannot decode array into a map[string]string" if the content is empty.
The data is written by PHP code, sometimes it has value _ {"hellow": "world"}, but sometimes it is _[] |
| Comments |
| Comment by Isabella Siu (Inactive) [ 07/Oct/20 ] |
|
While it is intentional that arrays cannot be decoded into maps, you can register a custom map decoder that will handle empty arrays, like customDecoder.go |