UNPKG

@prefecthq/prefect-ui-library

Version:

This library is the Vue and Typescript component library for [Prefect 2](https://github.com/PrefectHQ/prefect) and [Prefect Cloud 2](https://www.prefect.io/cloud/). _The components and utilities in this project are not meant to be used independently_.

28 lines (23 loc) 437 B
import { isString } from '@/utilities/strings' export type JsonSafeParse = { success: boolean, value: unknown, } export function jsonSafeParse(value: unknown): JsonSafeParse { try { if (!isString(value)) { throw new Error() } const parsed = JSON.parse(value) return { success: true, value: parsed, } } catch { // silence is golden } return { success: false, value, } }