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_.

22 lines (18 loc) 543 B
import { isString } from '@/utilities/strings' export function parseUnknownJson(value: unknown): unknown { // If the incoming value is a string, we attempt to parse it as JSON. if (isString(value)) { try { const parsed = JSON.parse(value) // If the parsed value isn't a string, we return it. if (!isString(parsed)) { return parsed } // Otherwise, we return the original value, since strings are valid JSON. return value } catch { // silence is golden } } return value }