var str = '1:One,2:Two';
// Split the string by commas to get individual key-value pairs
var pairs = str.split(',');
// Create an empty object to store the converted data
var data = {};
// Loop through each key-value pair
$.each(pairs, function(index, pair) {
// Split the pair by colon to get the key and value
var keyValue = pair.split(':');
// Trim any leading or trailing whitespace from the key and value
var key = $.trim(keyValue[1]);
var value = $.trim(keyValue[0]);
// Add the key-value pair to the data object
data[key] = value;
});
console.log(data);