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)) {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user