(object: unknown)
| 316 | } |
| 317 | |
| 318 | export function toJsonObject(object: unknown): unknown { |
| 319 | // When using plainToInstance or plainToClass, Map types will need to be converted to a JSON object |
| 320 | // https://github.com/typestack/class-transformer/issues/1256#issuecomment-1175153352 |
| 321 | return JSON.parse( |
| 322 | JSON.stringify(object, (_, value: unknown) => { |
| 323 | if (value instanceof Map) { |
| 324 | return mapToObject(value); |
| 325 | } |
| 326 | return value; |
| 327 | }) |
| 328 | ); |
| 329 | } |
| 330 | |
| 331 | export function mapToObject(map: Map<string | number, unknown>): Record<string | number, unknown> { |
| 332 | // XXX can use Object.entries with newer versions of node.js |
no test coverage detected