Demo entry 6646535

asfasfasfasf

   

Submitted by anonymous on Oct 17, 2017 at 10:41
Language: HTML. Code size: 2.2 kB.

<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Test</title>
</head>

<body>
    <script type="text/javascript">
        var json = {
            "info": {
                "name": "张三",
                "brith": "",
                "sex": "  ",
                "eduction": 4,
                "wechat": "wangyu_gz",
                "email": "wangyu@4sone.com",
                "hobby": [105, 406, 507],
                "tel": "18515070534",
                "family": {
                    "situation": 5,
                    "earning": 3,
                    "location": {
                        "province": "110000",
                        "city": "110000",
                        "region": "110101",
                        "addr": "辉煌国际70-3-3"
                    }
                },
                "job": {
                    "company": "北京云杉思维科技有限公司",
                    "occupation": 205,
                    "location": {
                        "province": "110000",
                        "city": "110000",
                        "region": "110101",
                        "addr": "辉煌国际写字楼"
                    }
                }
            }
        };
        test(json);

        function test(json) {
            for (var obj in json) {
                var tempObj = json[obj]
                if (IsJson(tempObj)) {
                    test(tempObj)
                }
                if (tempObj == undefined || tempObj == null || trim(tempObj) == "") {
                    alert(obj);
                }
            }
        }

        function IsJson(obj) {
            var isjson = typeof (obj) == "object" && Object.prototype.toString.call(obj).toLowerCase() ==
                "[object object]" && !obj.length;
            return isjson;
        }

        function trim(str) {
            if (typeof str == 'string') {
                return str.replace(/(^\s+)|(\s+$)/g, "");
            } else {
                return str;
            }
        }
    </script>

</body>

</html>

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).