码迷,mamicode.com
首页 > Web开发 > 详细

JSON格式校验

时间:2018-09-17 19:33:58      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:ros   cal   color   ons   type   ice   view   font   asc   

<!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>

 

JSON格式校验

标签:ros   cal   color   ons   type   ice   view   font   asc   

原文地址:https://www.cnblogs.com/mengfangui/p/9663558.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!