mirror of
https://github.com/Unleash/unleash.git
synced 2024-11-01 19:07:38 +01:00
13 lines
351 B
TypeScript
13 lines
351 B
TypeScript
|
export const validateJsonString = (value: string): boolean => {
|
||
|
// from https://stackoverflow.com/a/20392392
|
||
|
try {
|
||
|
const parsedStr = JSON.parse(value);
|
||
|
if (parsedStr && typeof parsedStr === 'object') {
|
||
|
return true;
|
||
|
}
|
||
|
} catch (err) {}
|
||
|
|
||
|
// an error is considered a non valid json
|
||
|
return false;
|
||
|
};
|