isJSON function returns true, when given string is valid JSON, and false otherwise
This commit is contained in:
parent
0c29d120ef
commit
32948dba92
8
packages/components/textarea/utils/isJSON.js
Normal file
8
packages/components/textarea/utils/isJSON.js
Normal file
@ -0,0 +1,8 @@
|
||||
export function isJSON(jsonString) {
|
||||
try {
|
||||
const parsedJson = JSON.parse(jsonString);
|
||||
return parsedJson && typeof parsedJson === "object";
|
||||
} catch (e) {}
|
||||
|
||||
return false;
|
||||
}
|
Loading…
Reference in New Issue
Block a user