Note. . This gives the format [{n1:'v1'}, {n2:'v2'}] rather than the format { n1: 'v1', n2: 'v2' } , which better matches the Hashtable description.
If you can trust your input in all other respects except the delimiter, then it will look something like this:
function splitByDelimiter(input, delimiter) { var parts = input.split(delimiter); var output = []; for(var i = 0; i < parts.length; i++) { var item = {}; var keyValue = parts[i].split('='); item[keyValue[0]] = keyValue[1]; output.push(item); } return output; } splitByDelimiter('n1=v1;n2=v2;n3=v3', ';')
source share