【发布时间】:2019-04-12 12:57:55
【问题描述】:
我需要过滤字典数组,但在我的结构中,一些值是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,
}
},
所以在上面的结果中我需要删除字典的第一个数组以及那个数组。
【问题讨论】:
-
1 ->删除字典的第一个数组以及那个数组请指定你说的是哪个数组?2 ->需要过滤字典数组根据你想过滤数据的键吗? -
如果
trips对象为 null 我需要删除孔对象 { "date": "2019-04-12 00:00:00", "points": 825, "trips": [ {“id”:108,“trip_detail”:“”} -
这似乎是 JSON。首先对其进行序列化。那我们看看吧。你有什么尝试吗?您还想在解析时过滤或跳过它们吗?
-
我使用了以下 Predicate ,现在可以了 [NSPredicate predicateWithFormat:@"trip_detail != null"]];
-
@Nandhakumar 您需要在问题中显示您的代码。 Edit 问题并添加(作为文本)您的相关代码。清楚地显示您需要帮助的地方;清楚地显示预期和实际结果。
标签: objective-c nsarray nsdictionary