UNPKG

@gent-js/gent

Version:

template-based data generator.

19 lines (18 loc) 445 B
export function parseJsonable(input, jsonableTransformer) { let jsonValue; try { jsonValue = JSON.parse(input); } catch (error) { console.error(error); jsonValue = undefined; } if (jsonValue === undefined) { return undefined; } const jsonableValue = jsonableTransformer(jsonValue); if (jsonableValue === undefined) { return undefined; } return jsonableValue; }