1. 程式人生 > >JSON格式校驗

JSON格式校驗

scrip ble style javascrip soft width let spa view

<!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格式校驗