Skip to content

Commit 9c657bc

Browse files
author
daffl
committed
Fixed JSON converter bug
1 parent fb444bd commit 9c657bc

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/dform.converters.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
},
2323
"integer" :
2424
{
25-
"type" : "text",
26-
"validate" : "int"
25+
"type" : "text"
2726
}
2827
}
2928
}
@@ -36,25 +35,29 @@
3635
return data;
3736
},
3837

39-
"json" : function(data)
38+
"json" : function(data, path)
4039
{
4140
var converters = $.dform.options.converters.json.types;
4241
var getElements = function(obj)
4342
{
4443
var result = [];
45-
$.each(data, function(key, value)
44+
$.each(obj, function(key, value)
4645
{
4746
var instance = typeof (value);
4847
var element;
49-
if (instance == 'object')
48+
if($.isArray(value))
49+
{
50+
alert(key + ' is an array');
51+
} else if($.isPlainObject(value))
5052
{
5153
element =
5254
{
5355
'type' : 'fieldset',
54-
'caption' : key
56+
'caption' : key,
57+
'elements' : getElements(value)
5558
};
56-
// element.elements = getElements(value);
57-
} else
59+
}
60+
else
5861
{
5962
var baseElement = converters[instance] || { 'type' : 'text' };
6063
element = $.extend(baseElement, { 'caption' : key, 'name' : key, 'value' : value });
@@ -63,6 +66,7 @@
6366
});
6467
return result;
6568
};
69+
6670
return {
6771
"type" : "form",
6872
"elements" : getElements(data)

0 commit comments

Comments
 (0)