拼接json(只能用双引号的情况下)

<!DOCTYPE html>
<html>
    <head lang="en">
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title></title>
        <script src="https://cdn.staticfile.org/jquery/3.3.1/jquery.js"></script>
    </head>
    <body>
        <!-- 只能用双引号的情况下拼接 -->
        <script>
            let a = "{\"state\":\"no\"}",
                b = "{\"code\":\"" + 1 + "\",\"message\":\"" + 2 + "\",\"requestid\":\"" + 3 + "\",\"SubsId\":\"" + 4 +
                "\",\"SecretNo\":\"" + 5 + "\"}";
            console.log(a);
            console.log(b);
        </script>
    </body>
</html>

 

posted @ 2018-11-07 15:25  我爱大西瓜  阅读(388)  评论(0编辑  收藏  举报