I have a function, SWFUpload_config, which takes an argument, post_params_arr – an object.
post_params_arr = {"ajaxtask":"swfupload_files", "param": "2012"}
I need to parse that post_params_arr and dynamically add keys and values to swfu_settings in the following way (please notice that swfu_settings has by default ‘SWFSESSID’ : session_id and all other keys:values must be added from post_params_arr):
function SWFUpload_config (post_params_arr) {
var swfu_settings = {
'SWFSESSID' : session_id,
'ajaxtask' : 'swfupload_files',
'param' : '2012'
};
}
How can I achieve that? How would I parse post_params_arr inside swfu_settings where I am assigning keys and values?
The same way you’d access any other object…
Or do you mean it’s JSON? If you have jQuery, parse it using
jQuery.parseJSON; otherwise, useJSON.parseand fall back oneval('(' + post_params_arr + ')').If you need to shallow-clone the object for some reason, a
for inloop will work: