how to Marshal a map of float64 type e.g ( map[float64] []interface ) into json object ?
according to json.marshal() documentation map’s keys must be either string or integer i tried to marshal map[float64] string maps into json which gave me error of "type unsupported"
Thanks in advance
- Try not to do this. Always remember,
10 * n
is not necessarily equal ton + n + n + n + n + n + n + n + n + n
. - If you really have to stick to float keys, stringify them first.
2 Likes
stingify is a better option actually it is needed in my project to encode a map which is map[ float64 ][ ]data_structure
Thanks btw for your response
As I said, you shouldn’t do this.
Find another way to encode your data. If you keep the float you will regret that decission in the future.
3 Likes
ok i will look into other encoding and thanks for alarming me at the begging
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.