sync.Map to JSON


(Ben) #1

Hello everyone,
I’m trying to convert sync.Map to JSON with json.Marshal but i get empty json “{}”.

Example:
https://play.golang.org/p/HNzOuuMQt21

I’m looking for a solution to convert sync.Map to json except convert it to Map (go over sync.Map and copy keys and values to Map) and convert the Map to JSON.

Thanks :slight_smile:


(Onezino Moreira) #2

Problably u’ll need to convert before encode. https://play.golang.org/p/PdSjIcV8iJh


(Ben) #3

Thats exacly what I’m trying to avoid, i guess there is no other solution…

Thank you!