nvidia Apex Install Flying

2023-01-08   ES  

Death is not terrible, the terrible thing is that you have not really lived.


relies on jQuery, the following is jQuery.json code:

(function (factory) {
    
    if (typeof define === 'function' && define.amd) {
        // AMD
        define(['jquery'], factory);
    } else if (typeof exports === 'object') {
        // CommonJS
        factory(require('jquery'));
    } else {
        // Browser globals
        factory(jQuery);
    }
}


(function ($) {
    
    'use strict';

    var escape = /["\\\x00-\x1f\x7f-\x9f]/g,
        meta = {
            '\b': '\\b',
            '\t': '\\t',
            '\n': '\\n',
            '\f': '\\f',
            '\r': '\\r',
            '"': '\\"',
            '\\': '\\\\'
        },
        hasOwn = Object.prototype.hasOwnProperty;


    $.toJSON = typeof JSON === 'object' && JSON.stringify ? JSON.stringify : function (o) {
    
        if (o === null) {
            return 'null';
        }

        var pairs, k, name, val,
            type = $.type(o);

        if (type === 'undefined') {
            return undefined;
        }


        if (type === 'number' || type === 'boolean') {
            return String(o);
        }
        if (type === 'string') {
            return $.quoteString(o);
        }
        if (typeof o.toJSON === 'function') {
            return $.toJSON(o.toJSON());
        }
        if (type === 'date') {
            var month = o.getUTCMonth() + 1,
                day = o.getUTCDate(),
                year = o.getUTCFullYear(),
                hours = o.getUTCHours(),
                minutes = o.getUTCMinutes(),
                seconds = o.getUTCSeconds(),
                milli = o.getUTCMilliseconds();

            if (month < 10) {
                month = '0' + month;
            }
            if (day < 10) {
                day = '0' + day;
            }
            if (hours < 10) {
                hours = '0' + hours;
            }
            if (minutes < 10) {
                minutes = '0' + minutes;
            }
            if (seconds < 10) {
                seconds = '0' + seconds;
            }
            if (milli < 100) {
                milli = '0' + milli;
            }
            if (milli < 10) {
                milli = '0' + milli;
            }
            return '"' + year + '-' + month + '-' + day + 'T' +
                hours + ':' + minutes + ':' + seconds +
                '.' + milli + 'Z"';
        }

        pairs = [];

        if ($.isArray(o)) {
            for (k = 0; k < o.length; k++) {
                pairs.push($.toJSON(o[k]) || 'null');
            }
            return '[' + pairs.join(',') + ']';
        }


        if (typeof o === 'object') {
            for (k in o) {

                if (hasOwn.call(o, k)) {

                    type = typeof k;
                    if (type === 'number') {
                        name = '"' + k + '"';
                    } else if (type === 'string') {
                        name = $.quoteString(k);
                    } else {
                        continue;
                    }
                    type = typeof o[k];


                    if (type !== 'function' && type !== 'undefined') {
                        val = $.toJSON(o[k]);
                        pairs.push(name + ':' + val);
                    }
                }
            }
            return '{' + pairs.join(',') + '}';
        }
    };


    $.evalJSON = typeof JSON === 'object' && JSON.parse ? JSON.parse : function (str) {
    
        /*jshint evil: true */
        // 1. For the JSON string returned by the server, if the Jquery asynchronous request does not make a type, or accept it in a string,
        // So you need to do an objectized treatment, the method is either too troublesome, or the string is executed once in the eval ().
        // This method is also suitable for obtaining JSON objects in ordinary JavaScipt. The following example is:

        // Convert to JSON object
        return eval('(' + str + ')');
    };


    $.secureEvalJSON = typeof JSON === 'object' && JSON.parse ? JSON.parse : function (str) {
    
        var filtered =
            str
            .replace(/\\["\\\/bfnrtu]/g, '@')
            .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
            .replace(/(?:^|:|,)(?:\s*\[)+/g, '');

        if (/^[\],:{}\s]*$/.test(filtered)) {
            /*jshint evil: true */
            return eval('(' + str + ')');
        }
        throw new SyntaxError('Error parsing JSON, source is not valid.');
    };


    $.quoteString = function (str) {
    
        if (str.match(escape)) {
            return '"' + str.replace(escape, function (a) {
    
                var c = meta[a];
                if (typeof c === 'string') {
                    return c;
                }
                c = a.charCodeAt();
                return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
            }) + '"';
        }
        return '"' + str + '"';
    };

}));

jsonDemo.aspx:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="js/jquery-1.10.2-min.js" type="text/javascript"></script>
    <script src="js/jquery.json.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
     
            var obj = new Object();
            obj.name = "Zhang San";

            obj.age = "12";

            obj.job = "php";

            // Convert to json string
            var strjson = $.toJSON(obj);

            $(".strjson").text(strjson);


        });

    </script>

    <script type="text/javascript">
        var thing = { plugin: 'jquery-json', version: 2.3 };

        // Convert to json string
        var encoded = $.toJSON(thing);
        // '{"plugin":"jquery-json","version":2.3}'


        // The reason is: Eval itself. Since JSON starts and ends in the way of "{}", in JS, it will be treated as a statement block, so it must be mandatory to convert it into an expression.
        // The purpose of adding brackets is to force the EVAL function to force the expression in parentheses into objects when processing the JavaScript code, instead of being executed as a statement.
        // Take an example, for example, the object of the object is {}. If the brackets of the outer layer are not added, then EVAL will identify the bracket as the start and end of the JavaScript code block, then {} will be considered to be executed A sentence empty sentence.
        // So the following two execution results are different:
        //alert(eval("{}"); // return undefined
        //alert(eval("({})");// return object[Object]
        // For this writing, you can see everywhere in JS.
        //, such as: (function ()) {} (); when doing closure operation, etc.
        var name = $.evalJSON(encoded).plugin;
        // "jquery-json"

        var version = $.evalJSON(encoded).version;

    </script>

    <script type="text/javascript">
        // The second analysis method is to complete the use of the Function object. Its typical application is to analyze the data data analysis under the AJAX method in jquery
        var json='{"name":"CJ","age":18}';

        data =(new Function("","return "+json))();
        // At this time, the data is a JSON object that will be parsed into a JSON object


        var dataStr="{root: " +
            "[{name:'1',value:'0'}," +
            "{name: '6101', value: 'Beijing'}," +
            "{name: '6102', value: 'Tianjin City'}," +
            "{name: '6103', value: 'Shanghai'}," +
            "{name: '6104', value: 'Chongqing City'}," +
            "{name: '6105', value: 'Weinan City'}," +
            "{name: '6106', value: 'Yan'an City'}," +
            "{name: '6107', value: 'Hanzhong City'}," +
            "{name: '6108', value: 'Yulin City'}," +
            "{name: '6109', value: 'Ankang City'}," +
            "{name: '6110', value: 'Shangluo City'}]}";

        var dataObj=eval("("+dataStr+")");// Convert to JSON object
        $.each(dataObj.root, function(idx, item) {
     
            if (idx == 0) {
                return true;
            }
            // Output the name and value of each root sub -object
            //$(".Totalstr").append("name:" + item.name + ",value:" + item.value);
        }); 
    </script>


    <script type="text/javascript">
        // String represents, intelligent transition quotes
        var myquoteString = $.quoteString('"Where are we going?", Children ask .we laughed and kept saying "see u soon", but inside we both knew we \' d never see each Other Again. We laughed and said goodbye to goodbye Far forever. ')
        alert(myquoteString);
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>json string:<span class="strjson"></span>
    </div>
    <hr />

    </form>
</body>
</html>

Results As shown in Figure:


source

Related Posts

C ++ open source cross-platform log library GLOG learning research (2)-macro use

Steam how to convert the district service (take PES2021 as an example)

2018 West Post Linux Group Na Na Na Na

116 ACM/ICPC Dalian Division F (Thinking+Two -point+Instant Yuan)

nvidia Apex Install Flying

Random Posts

winform Get the attribute of the file under the specified path Add a [Textbox] control to the

UILABEL detailed explanation 3Guu

IDEA import Maven project Error: Java: -Source 1.5 does not support the Diamond operator (please use -Source 7 or higher version to enable Diamond operators)

CSS style Initial (default) and Inherit (inheritance) and Unset

problems encountered in work in 2016 11-20