fix(utils): ios to filter out null values (#10117)

This commit is contained in:
Samuel Schultze
2022-11-30 18:49:30 -03:00
committed by GitHub
parent 5b1c9708b2
commit 47231145ac

View File

@@ -92,14 +92,15 @@ export function dataSerialize(data: any, wrapPrimitives: boolean = false) {
}
if (Array.isArray(data)) {
return NSArray.arrayWithArray((<any>data).map(dataSerialize));
return NSArray.arrayWithArray(data.map((el) => dataSerialize(el, wrapPrimitives)).filter((el) => el !== null));
}
let node = {} as any;
Object.keys(data).forEach(function (key) {
let value = data[key];
node[key] = dataSerialize(value, wrapPrimitives);
});
const node = Object.fromEntries(
Object.entries(data)
.map(([key, value]) => [key, dataSerialize(value, wrapPrimitives)])
.filter(([, value]) => value !== null)
);
return NSDictionary.dictionaryWithDictionary(node);
}