@snickerdoodlelabs/common-utils
Version:
Common utils classes used in snickerdoodlelabs projects
17 lines (13 loc) • 343 B
text/typescript
import { injectable } from "inversify";
import { IJsonUtils } from "@common-utils/interfaces/index.js";
()
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;
}
}
}