MCPcopy
hub / github.com/simstudioai/sim / parseJsonField

Function parseJsonField

apps/sim/tools/zoominfo/utils.ts:25–36  ·  view source on GitHub ↗
(value: unknown, fieldName: string)

Source from the content-addressed store, hash-verified

23}
24
25export function parseJsonField<T>(value: unknown, fieldName: string): T {
26 if (typeof value !== 'string') return value as T
27 const trimmed = value.trim()
28 if (!trimmed) {
29 throw new Error(`${fieldName} is required`)
30 }
31 try {
32 return JSON.parse(trimmed) as T
33 } catch (error) {
34 throw new Error(`${fieldName} must be valid JSON: ${getErrorMessage(error)}`)
35 }
36}
37
38/**
39 * Normalize a JSON-array string, real array, or comma-separated string into a

Callers 2

enrich_contacts.tsFile · 0.90

Calls 2

getErrorMessageFunction · 0.90
parseMethod · 0.80

Tested by

no test coverage detected