Co-authored-by: Liyas Thomas <hi@liyasthomas.com> Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com> Co-authored-by: liyasthomas <liyascthomas@gmail.com> Co-authored-by: Rishabh Agarwal <45998880+RishabhAgarwal-2001@users.noreply.github.com>
10 lines
270 B
TypeScript
10 lines
270 B
TypeScript
import * as O from "fp-ts/Option"
|
|
|
|
/**
|
|
* Checks and Parses JSON string
|
|
* @param str Raw JSON data to be parsed
|
|
* @returns Option type with some(JSON data) or none
|
|
*/
|
|
export const safeParseJSON = (str: string): O.Option<object> =>
|
|
O.tryCatch(() => JSON.parse(str))
|