There is an issue within the json import where empty map values cannot be passed at any level into the marshal method. This fixes this issue by translating any empty map value into map[string]interface{}. Although it could be argued that assuming a key type of string is a strange assumption, there should not be any side effects due to it's inherent emptiness.
Furthermore, it could be argued that this solution should be handled by the json import itself. I did not believe that to be the ideal use case as it would require heavy use of reflect in a relatively simple package. By placing it here, there is no additional reflection needed (apart from when making the map).
There is an issue within the
json
import where empty map values cannot be passed at any level into themarshal
method. This fixes this issue by translating any empty map value intomap[string]interface{}
. Although it could be argued that assuming a key type ofstring
is a strange assumption, there should not be any side effects due to it's inherent emptiness.Furthermore, it could be argued that this solution should be handled by the
json
import itself. I did not believe that to be the ideal use case as it would require heavy use of reflect in a relatively simple package. By placing it here, there is no additional reflection needed (apart from when making the map).