Improve flatten
This commit is contained in:
parent
88fd79757b
commit
d98ebab393
|
@ -80,6 +80,7 @@ class Serializer {
|
||||||
this.parent;
|
this.parent;
|
||||||
this._fields = new Map();
|
this._fields = new Map();
|
||||||
this.min = Number(element.getAttribute("min") || -1);
|
this.min = Number(element.getAttribute("min") || -1);
|
||||||
|
this.flatten = element.hasAttribute("flatten")
|
||||||
|
|
||||||
this.required = element.getAttribute("required") !== null || this.min != -1;
|
this.required = element.getAttribute("required") !== null || this.min != -1;
|
||||||
|
|
||||||
|
@ -174,7 +175,7 @@ class Serializer {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(k == "") {
|
if(k == "") {
|
||||||
if(f[key].flatten){
|
if(f[key].flatten || this.flatten){
|
||||||
json[key].push(d);
|
json[key].push(d);
|
||||||
} else {
|
} else {
|
||||||
json[key] = d;
|
json[key] = d;
|
||||||
|
@ -183,7 +184,7 @@ class Serializer {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if(f[key].flatten){
|
if(f[key].flatten || this.flatten){
|
||||||
json[k].push(d);
|
json[k].push(d);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue