mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix(utils): ios to filter out null values (#10117)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user