UNPKG

@pipedream/canny

Version:

Pipedream canny Components

28 lines (23 loc) 465 B
export const parseObject = (obj) => { if (!obj) return undefined; if (typeof obj === "string") { try { return JSON.parse(obj); } catch (e) { return obj; } } if (Array.isArray(obj)) { return obj.map(parseObject); } if (typeof obj === "object" && obj !== null) { return Object.fromEntries(Object.entries(obj).map(([ key, value, ]) => [ key, parseObject(value), ])); } return obj; };