Skip to content

Instantly share code, notes, and snippets.

@chilts
Created January 11, 2012 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chilts/1593849 to your computer and use it in GitHub Desktop.
Save chilts/1593849 to your computer and use it in GitHub Desktop.
Weird data structure into an object
var str = "a:0,1,2,3|b:4,5,6|c:0,2";
var a = {};
str.split('|').forEach(function(v) {
var s = v.split(':');
a[s[0]] = s[1].split(',');
});
console.log(a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment