<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-equiv="X-UA-Compatible" content="ie=edge" /> <title>JSON格式校验</title> </head> <body> <script type="text/javascript"> let a = { "age": function() {} } function isJson(str) { try { JSON.parse(str); } catch(e) { return false; } return true; } console.log(isJson(a)) </script> </body> </html>
原文地址:https://www.cnblogs.com/mengfangui/p/9663558.html
时间: 2024-12-31 20:49:21