Skip to content
Advertisement

Changing the order of the Object keys….

var addObjectResponse = [{
    'DateTimeTaken': '/Date(1301494335000-0400)/',
    'Weight': 100909.090909091,
    'Height': 182.88,
    'SPO2': '222.00000',
    'BloodPressureSystolic': 120,
    'BloodPressureDiastolic': 80,
    'BloodPressurePosition': 'Standing',
    'VitalSite': 'Popliteal',
    'Laterality': 'Right',
    'CuffSize': 'XL',
    'HeartRate': 111,
    'HeartRateRegularity': 'Regular',
    'Resprate': 111,    
    'Temperature': 36.6666666666667,
    'TemperatureMethod': 'Oral',    
    'HeadCircumference': '',    
}];

This is a sample object which i am getting from back end, now i want to change the order of the object. I don’t want to sort by name or size… i just want to manually change the order…

Advertisement

Answer

if you want to manually reorder. simply create new object and assign values using old object.

var newObject= [{
    'DateTimeTaken': addObjectResponse.DateTimeTaken,
    'Weight': addObjectResponse.Weight,
    'Height': addObjectResponse.Height,
    'SPO2': addObjectResponse.SPO2 
}];
Advertisement