jQuery: ordering an array from a json one -


reqi have json this:

[{"type":"checkbox",  "title":"an example",  "values":   {"2": {"value":"val1", "required":"true"},     "3": {"value":"val2", "required":"false"},     "4": {"value":"val3", "required":"false"},    } }, , on] 

i have jquery function

var fromjson = function (json) {     var values = '';     var options = false;     // parse json     $(json).each(function () {       // type "checkbox"       if (this.type === 'checkbox') {         options = [this.title];         values = [];         $.each(this.values, function () {           values.push([this.value, this.required]);         });       }       // other types                        ...     }); }; 

i $.each(this.values, function () { values.push([this.value, this.baseline]); }); push values in right order, how do?

is there way order values according "2", "3", "4",... before doing push?

edit

i've resolved with

   $.each(this.values, function (key) {           values[key-2]=[this.value, this.required];         }); 


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -