File tree Expand file tree Collapse file tree 1 file changed +15
-21
lines changed Expand file tree Collapse file tree 1 file changed +15
-21
lines changed Original file line number Diff line number Diff line change @@ -324,24 +324,18 @@ func fnv32(key string) uint32 {
324
324
return hash
325
325
}
326
326
327
- // Concurrent map uses Interface{} as its value, therefor JSON Unmarshal
328
- // will probably won't know which to type to unmarshal into, in such case
329
- // we'll end up with a value of type map[string]V, In most cases this isn't
330
- // out value type, this is why we've decided to remove this functionality.
331
-
332
- // func (m *ConcurrentMap) UnmarshalJSON(b []byte) (err error) {
333
- // // Reverse process of Marshal.
334
-
335
- // tmp := make(map[string]V)
336
-
337
- // // Unmarshal into a single map.
338
- // if err := json.Unmarshal(b, &tmp); err != nil {
339
- // return nil
340
- // }
341
-
342
- // // foreach key,value pair in temporary map insert into our concurrent map.
343
- // for key, val := range tmp {
344
- // m.Set(key, val)
345
- // }
346
- // return nil
347
- // }
327
+ // Reverse process of Marshal.
328
+ func (m ConcurrentMap [V ]) UnmarshalJSON (b []byte ) (err error ) {
329
+ tmp := make (map [string ]V )
330
+
331
+ // Unmarshal into a single map.
332
+ if err := json .Unmarshal (b , & tmp ); err != nil {
333
+ return nil
334
+ }
335
+
336
+ // foreach key,value pair in temporary map insert into our concurrent map.
337
+ for key , val := range tmp {
338
+ m .Set (key , val )
339
+ }
340
+ return nil
341
+ }
You can’t perform that action at this time.
0 commit comments