Browse Source

feat(nc-gui): add parseProp & stringifyProp

pull/5307/head
Wing-Kam Wong 2 years ago
parent
commit
bd77a065e3
  1. 17
      packages/nc-gui/utils/parseUtils.ts

17
packages/nc-gui/utils/parseUtils.ts

@ -0,0 +1,17 @@
export function parseProp(v: any): any {
if (!v) return
try {
return typeof v === 'string' ? JSON.parse(v) : v
} catch {
return {}
}
}
export function stringifyProp(v: any): string | void {
if (!v) return
try {
return typeof v === 'string' ? v : JSON.stringify(v)
} catch {
return '{}'
}
}
Loading…
Cancel
Save