Skip to content
Create a gist now

Instantly share code, notes, and snippets.

var merge = function(merged, source){
for(var property in source) {
if( typeof source[property] === "object" &&
typeof merged[property] !== "undefined") {
merge(merged[property], source[property]);
} else {
merged[property] = source[property];
return merged;
var build = function(name, value){
return (function gerarJSON(json, name, value){
var hierarquia = name.split(".");
var propriedade = hierarquia.shift();
json[propriedade] = (hierarquia.length > 0)?
gerarJSON({}, hierarquia.join(".", value)):value;
return json;
})({}, name, value);
getJSON: function(){
var json = {};
.each(function(index, input){
var parcial = build( $(input).attr("name"), $(input).val());
merge(json, parcial);
return json;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.