UNPKG

@snickerdoodlelabs/common-utils

Version:
17 lines (13 loc) 343 B
import { injectable } from "inversify"; import { IJsonUtils } from "@common-utils/interfaces/index.js"; @injectable() export class JsonUtils implements IJsonUtils { constructor() {} public safelyParseJSON<T>(json: string): T | null { try { return JSON.parse(json) as T | null; } catch (e) { return null; } } }