Every line of 'jquery array to json' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
42 function translateArraysToJSON(keys, value) { 43 const MyJSON = {}; 44 let index = 0; 45 for (const item of keys) { 46 const currentKeys = item.split("."); 47 let currentKey = ""; 48 for (let el of currentKeys) { 49 currentKey += `["` + el + `"]`; 50 if (!eval("MyJSON" + currentKey)) { 51 eval("MyJSON" + currentKey + "={}"); 52 } 53 } 54 eval("MyJSON" + currentKey + "=" + "`" + value[index++] + "`"); 55 } 56 return MyJSON; 57 }
60 function json(data) { 61 switch (data) { 62 case '__NULL__': 63 case '__BLANK_ARRAY__': 64 return data === '__NULL__' ? 'null' : '[]'; 65 default: 66 return JSON.stringify(data || null, null, ' ') 67 .replace(/\n/g, '') 68 .replace(/^(\{|\[) /, '$1'); 69 } 70 }
40 function getJsonString(obj) { 41 try { 42 return JSON.stringify(obj); 43 } catch(e) {} 44 return ""; 45 }
77 function jsonToArray(p_name) 78 { 79 var array = []; 80 var jsonArray = json.get(p_name); 81 for (var i = 0, j = jsonArray.length(); i < j; i++) 82 { 83 array.push(jsonArray.get(i)); 84 } 85 return array; 86 }
111 export function parseJson(json) { 112 return /** @type {?JsonObject} */ (JSON.parse(/** @type {string} */ (json))); 113 }
26 export function parseJson(json) { 27 return JSON.parse(json, function (k, v) { 28 if (v.indexOf && v.indexOf('function') > -1) { 29 try { 30 return eval('(function(){return ' + v + ' })()') 31 } catch (e) { 32 console.error(`[form-create]解析失败:${v}`); 33 return undefined; 34 } 35 } 36 return v; 37 }); 38 }
21 function jsonify (obj) { 22 var jsonObj, 23 type = objType(obj); 24 25 try { 26 if (type == 'Undefined') { 27 jsonObj = 'undefined'; 28 } else if (obj !== obj) { 29 jsonObj = 'NaN'; 30 } else { 31 jsonObj = JSON.parse(JSON.stringify(obj)); 32 } 33 34 } catch (e) { 35 if (type.match('Element')) { 36 jsonObj = obj.outerHTML.replace(obj.innerHTML, ''); 37 } else if (type == 'Text') { 38 jsonObj = textOmit(obj.textContent); 39 } else if (type == 'Array' || type == 'NodeList') { 40 var array = []; 41 obj = slice.call(obj); 42 43 obj.forEach(function (item) { 44 array.push(jsonify(item)); 45 }); 46 jsonObj = array; 47 } else if (type == 'Object') { 48 var keys = Object.keys(obj), 49 object = {}; 50 keys.forEach(function (key) { 51 object[key] = jsonify(obj[key]); 52 }); 53 jsonObj = object; 54 } else if (type == 'Function') { 55 jsonObj = textOmit(obj.toString()); 56 } else if (type == 'global' || type == 'HTMLDocument') { 57 var keys = Object.keys(obj), 58 object = {}; 59 keys.forEach(function (key) { 60 object[key] = objType(obj[key]); 61 }); 62 jsonObj = object; 63 } else { 64 jsonObj = toString.call(obj); 65 } 66 } 67 68 return jsonObj; 69 }
15 function arrayParser(json) { 16 var result = '['; 17 for(var i=0;i