Last active
October 5, 2016 08:12
-
-
Save RCrowt/d3c4423ab2e51222cec3dbe7301c3c3b 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
| /** | |
| * Convert a multidimensional array/object to a single dimenstion object. | |
| * @param data {array|object} Input data. | |
| * @param prefix {string} key prefix. | |
| */ | |
| var fn_dotArray = function (data, prefix) { | |
| var out = {}; | |
| $.each(data, function (k, v) { | |
| if (v !== null && typeof v == 'object') { | |
| $.extend(out, fn_dotArray(v, prefix + k + '.')); | |
| } else { | |
| out[prefix + k] = v; | |
| } | |
| }); | |
| return out; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment