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)) { 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; const node = Object.fromEntries(
Object.keys(data).forEach(function (key) { Object.entries(data)
let value = data[key]; .map(([key, value]) => [key, dataSerialize(value, wrapPrimitives)])
node[key] = dataSerialize(value, wrapPrimitives); .filter(([, value]) => value !== null)
}); );
return NSDictionary.dictionaryWithDictionary(node); return NSDictionary.dictionaryWithDictionary(node);
} }