You can't.
The keys of a map can be anything, including objects. But JSON syntax only allows strings as keys. So it's impossible in a general case.
My keys are guaranteed to be strings and my values will always be lists
In this case, you can use a plain object. It will have thosethese advantages:
- It will be able to be stringified to JSON.
- It will work on older browsers.
- It might be faster.