altair-graphql-core
Version:
Several of the core logic for altair graphql client
14 lines • 432 B
JavaScript
import JSONBigint from 'json-bigint';
/**
* Parses a JSON string into an object. Has support for BigInt and falls back to a default value if parsing fails.
*/
export const parseJson = (str, { defaultValue = {} } = {}) => {
try {
return JSONBigint.parse(str);
}
catch {
console.error('Could not parse JSON. Using default instead.');
return defaultValue;
}
};
//# sourceMappingURL=json.js.map