Created
October 27, 2015 16:12
-
-
Save duyet/728ae2e2a13ee34822a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = [ | |
{name: "otp_options[otp_option_value][5][otp]", value: "617"}, | |
{name: "otp_options[otp_option_value][10][otpx]", value: "617"}, | |
{name: "otp_options[otp_option_value][5][otpy]", value: "617"} | |
]; | |
var data = _.map(data, function(x) { | |
var tmp = x.name.match(/[A-z_-]+\[[^\]]+\]\[[^\]]+\]\[([^\]]+)\]/); | |
var key = tmp[1] || ''; | |
return { key: key, value: x.value }; | |
}) | |
data = _.object(_.pluck(data, 'key'), _.pluck(data, 'value')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment