var arr = Object.keys(typeARR); var str = ''; var len = arr.length; for(var i = 0;i<len;i++){ str += '{code : " ' + i '" + typeARR[i] + ' "},'; } str = str.substring(0,str.length - 1); var d = '[' + str + ']'; var json_obj = eval('(' + d
使用dynamic获取类型可变的json对象 Dictionary<string, object> dict = new Dictionary<string, object>(); List<dynamic> lst = new List<dynamic>() { new { aa = 1, bb = "2" } }; Type type = lst[0].GetType(); var ps = type.GetProperties();
//把url的参数部分转化成json对象 parseQueryString: function (url) { var reg_url = /^[^\?]+\?([\w\W]+)$/, reg_para = /([^&=]+)=([\w\W]*?)(&|$|#)/g, arr_url = reg_url.exec(url), ret = {}; if (arr_url && arr_url[1]) { var str_para = arr_url[1], result; w
获取json对象的长度跟获取一个普通对象或数组的方法不一样,json对象没有length属性,不能直接用.length直接获得. function getJsonLength(json){ var jsonLength = 0; for(var i in json){ jsonLength++; } return jsonLength; }
获取指定url参数值 /* 获取某url中的某参数值 调用:GetUrlQueryString("[url地址]","[参数名]"); */ function GetUrlQueryString(url,name){ var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); var r = url.substring(url.indexOf("