如果字典元素为空,如何过滤字典数组?

问题描述 投票:-2回答:1

我需要过滤字典数组,但在我的结构中,一些值是null

 "data": [
        {
            "date": "2019-04-12 00:00:00",
            "points": 825,
            "trips": [
                {
                    "id": 108,
                     "trip_detail": “<null>”
    }
        },
        {
            "date": "2019-04-11 00:00:00",
            "points": 2475,
            "trips": [
                {
                    "id": 73,
                     "trip_detail": {
                        "id": 53,
                        "score": 8.25,
                        "points": 825,
                    }
                },
                {
                    "id": 74,
                       "trip_detail": {
                        "id": 54,
                        "score": 8.25,
                        "points": 825,
                    }
                },

所以在上面的结果中我需要删除第一个字典数组以及该数组。

objective-c nsarray nsdictionary
1个回答
0
投票

使用filter循环遍历集合并返回仅包含与include条件匹配的元素的Array。

© www.soinside.com 2019 - 2024. All rights reserved.