
//定义map
    function Map() {
        this.container = {};
    }

//将key-value放入map中
    Map.prototype.put = function (key, value) {
        try {

            if (key != null && key != "")
                this.container[key] = value;

        } catch (e) {
            return e;
        }
    };

//将key-value放入map中
    Map.prototype.set = function (key, value) {
        try {

            if (key != null && key != "")
                this.container[key] = value;

        } catch (e) {
            return e;
        }
    };
//根据key从map中取出对应的value     
    Map.prototype.get = function (key) {
        try {

            return this.container[key];

        } catch (e) {
            return e;
        }
    };

//判断map中是否包含指定的key     
    Map.prototype.containsKey = function (key) {

        try {
            for (var p in this.container) {
                if (this.p == key)
                    return true;
            }

            return false;

        } catch (e) {
            return e;
        }

    }

//判断map中是否包含指定的value     
    Map.prototype.containsValue = function (value) {
        try {

            for (var p in this.container) {
                if (this.container[p] === value)
                    return true;
            }

            return false;

        } catch (e) {
            return e;
        }
    };


//删除map中指定的key
    Map.prototype.remove = function (key) {
        try {

            delete this.container[key];

        } catch (e) {
            return e;
        }
    };

//清空map
    Map.prototype.clear = function () {
        try {
            delete this.container;
            this.container = {};

        } catch (e) {
            return e;
        }
    };

//判断map是否为空
    Map.prototype.isEmpty = function () {

        if (this.keyArray().length == 0)
            return true;
        else
            return false;
    };

//获取map的大小
    Map.prototype.size = function () {

        return this.keyArray().length;
    }

//返回map中的key值数组
    Map.prototype.keyArray = function () {

        var keys = new Array();
        for (var p in this.container) {
            keys.push(p);
        }

        return keys;
    }

//返回map中的value值数组
    Map.prototype.valueArray = function () {

        var values = new Array();
        var keys = this.keyArray();
        for (var i = 0; i < keys.length; i++) {
            values.push(this.container[keys[i]]);
        }

        return values;
    }
function isJSON(obj)
{
    var isjson = typeof(obj) == "object" && Object.prototype.toString.call(obj).toLowerCase() == "[object object]" && !obj.length;
    return isjson;
}
//Map转JSON字符串
function MapToJSON(obj){
    var str='';
    try {
            for(var key in obj){
                var str1=obj[key];
                var str2=str1;
                if(str1.constructor==Object) {
                    str1=MapToJSON(str1);
                }
                if(str1.constructor==Number|| str1.constructor==Boolean)
                {
                    str=str+('"'+key+ '":' +str1+',');
                }
                else if((str1.constructor==String)&&(str2.constructor!==Object))
                {
                    str=str+('"'+key+ '":"' +str1+'",');
                }
                else if(str2.constructor==Object)
                {
                    str=str+('"'+key+ '":{' +str1+'},');
                }
                else if(str2.constructor==null)
                {
                    // str=str+('"'+key+ '":' +str1+',');
                    str=str+('"'+key+ '":"",');
                }
                else
                {
                    // str=str+('"'+key+ '":' +str1+',');
                    str=str+('"'+key+ '":"",');
                }
            }
            str=str.substr(0,str.length-1);
      }
    catch(e)
    {
    }
return str;
}
function ToJSON(obj)
{
    var str=MapToJSON(obj);
    return '{'+str+'}';
}
  // var config = new Map();
 //   config.put('afei', 25);
 //   var ss = config.get('afei');
 //   str = ss;
function test(str) {
    var config = new Map();

