javascript - Json Object split into json string -
the below info json object
var column = { "sno": [{ "group": "true", "sort": "true", "filter": "true", "type": "number", "min": 1, "max": 1000, "format": "{0:c}"}], "name": [{ "group": "true", "sort": "true", "type": "string", "columnmenu": "true"}], "city": [{ "group": "true", "type": "number", "filter": "true", "width": "100px", "columnmenu": "false"}] }; i need above info split array list without looping
first array list : ["sno", "name", "city"]
second array list : ["group", "sort", "filter", "type", "min", "max", "format", "group", "sort", "type", "columnmenu", "group", "type", "filter", "width", "columnmenu"]
third array list: ["true", "true", "true", "number", 1, 1000, "{0:c}", "true", "true", "string", "true", "true", "number", "true", "100px", "false"]
fourth array list : [7, 4, 5] // count of each attributes
please help me. new of field. otherwise cut down maximum no.of loops.
here got working when can have more keys in columns object.
var first_array = object.keys(column); var second_array = []; var third_array = []; var fourth_array = []; first_array.foreach(function(inner_key){ var keysininnerkey = object.keys(column[inner_key][0]); var valuesininnerkey = keysininnerkey.map(function(key){ homecoming column[inner_key][0][key]; }); second_array = second_array.concat(keysininnerkey); third_array = third_array.concat(valuesininnerkey); fourth_array.push(keysininnerkey.length); }); javascript jquery
No comments:
Post a Comment