Skip to main content
The 2024 Developer Survey results are live! See the results

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • 1
    It will work correctly with nested Maps because if a Map is converted into an Array, the Array members (including nested Maps) will be handled by the same logic. Commented Apr 23 at 7:25
  • That is a good point, I'm sorry for missing that. Let me remove my comment and add a new, factually correct one.
    – Stefnotch
    Commented Apr 23 at 13:37
  • This answer is very simple, but could be improved with an explanation. It also is only applicable when round-tripping is not a requirement, as there is no unambiguous way of JSON.parse()ing the result.
    – Stefnotch
    Commented Apr 23 at 13:39