处理JSON对象异常
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
const checkJson = str => {
|
||||
if (typeof str == 'object') {
|
||||
try {
|
||||
str = JSON.stringify(str)
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if (typeof str == 'string') {
|
||||
try {
|
||||
let obj = JSON.parse(str);
|
||||
|
||||
Reference in New Issue
Block a user