this is a simple text response:
response = " [{"prefixtodomid":"Sat17Dec2016103310GMT","todo_title":"task 3 changed","is_done_todo":false,"todo_subtitle_field":"\u00a0","prefix_pro_due_date":"","multicheckbox":false,"project_file_list":""},{"prefixtodomid":"Sat17Dec2016103313GMT","todo_title":"ce","is_done_todo":false,"todo_subtitle_field":"\u00a0","prefix_pro_due_date":"","multicheckbox":false,"project_file_list":""},{"prefixtodomid":"Sat17Dec2016103318GMT","todo_title":"dewdw","is_done_todo":false,"todo_subtitle_field":"\u00a0","prefix_pro_due_date":"","multicheckbox":false,"project_file_list":""},{"prefixtodomid":"Sat17Dec2016103321GMT","todo_title":"task 4","is_done_todo":false,"todo_subtitle_field":"\u00a0","prefix_pro_due_date":"","multicheckbox":false,"project_file_list":""},{"prefixtodomid":"Sat17Dec2016181953GMT","todo_title":"task 5","is_done_todo":false,"todo_subtitle_field":"\u00a0","prefix_pro_due_date":"","multicheckbox":false,"project_file_list":{"43":"http:\/\/example\/intra\/wp-content\/uploads\/2016\/11\/1project.png","26":"http:\/\/example\/intra\/wp-content\/uploads\/2016\/11\/2016--\u2039-Le-Blog-OSD-\u2014-WordPress_437.png"}},{"prefixtodomid":"Sat17Dec2016181957GMT","todo_title":"cewcwcwecw","todo_subtitle_field":"\u00a0","project_file_list":{"26":"http:\/\/example\/intra\/wp-content\/uploads\/2016\/11\/2016-10-16-15_26_04-Unyson-\u2039-Le-Blog-OSD-\u2014-WordPress_437.png"}}] "
i converted it to JSON as follows:
var obj = jQuery.parseJSON( response );
now I am iterating through the JSON object:
for (var i = 0; i<Object.keys(obj).length; i++) {
(function(index){
var haveimage = obj[i].project_file_list;
if(haveimage){
// some other logic here
}
})(i); // using the value of i
}
the issue is that 'haveimage' always displays images in the order of their IDs, even if we change the order in the response string. When parsed using parseJSON method, the order reverts based on the ID. Is there any solution to this problem?
If not, what alternative can be used instead of parseJSON?
Thank you :)