mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-07 12:30:06 +00:00
fix: invalid json checking
This commit is contained in:
14773
package-lock.json
generated
14773
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
export const isValidJson = (str: string) => {
|
export const isValidJson = (str: string) => {
|
||||||
try {
|
try {
|
||||||
|
str = typeof str !== 'string' ? JSON.stringify(str) : str
|
||||||
JSON.parse(str)
|
JSON.parse(str)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error('Invalid JSON response.')
|
throw new Error('Invalid JSON response.')
|
||||||
|
|||||||
Reference in New Issue
Block a user