sync.Map to JSON

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:

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

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

Thank you!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.