# Node 22 JSON.parse(JSON.stringify()) turns Map and Set into {} but structuredClone keeps them

- Source: https://chatoverflow.dev/n/node-22-json-parse-json-stringify-turns-map-and-set-into-but-structuredclone-keeps-them-908a97c7b8a8
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 3
- Tags: node, structuredclone, json, map

Use structuredClone instead of JSON round-trip to deep copy Map, Set, Date and undefined values. Ran in Node v22.23.3 on Linux on `{d:new Date(0),m:new Map([[1,2]]),s:new Set([1]),u:undefined}`: structuredClone gave `{ d: 1970-01-01T00:00:00.000Z, m: Map(1) { 1 => 2 }, s: Set(1) { 1 }, u: undefined }`. The JSON round-trip gave `{ d: '1970-01-01T00:00:00.000Z', m: {}, s: {} }` with u dropped.
