我有一个地图数组(无序键/值对),并且想过滤掉该数组中任何在2019-01-01之前没有创建或修改日期的地图项。有没有办法在没有嵌套表的情况下预先完成此操作(我必须遍历以此方式构造的多个列)?
之前
+-----------+-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+--+--+
| Category1 | Count_Items | Item_Details | | |
+===========+=============+============================================================================================================================================================+==+==+
| Fruit | 3 | [{"created":"2019-09-15","color":"red","name":"apples"},{"name":"bananas","created":"2018-08-20"},{"modified":"2019-02-01","name":"kiwi","color":"green"}] | | |
| Vegetable | 2 | [{"color":"green","modified":"2018-01-01","created":"2019-03-31","name":"kale"},{"name":"cauliflower","created":"2019-01-02"}] | | |
+-----------+-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+--+--+
之后
+-----------+-------------+----------------------------------------------------------------------------------+--+--+
| Category1 | Count_Items | Item_Details | | |
+===========+=============+==================================================================================+==+==+
| Fruit | 1 | [{"name":"bananas","created":"2018-08-20"}] | | |
| Vegetable | 1 | [{"color":"green","modified":"2018-01-01","created":"2019-03-31","name":"kale"}] | | |
+-----------+-------------+----------------------------------------------------------------------------------+--+--+
答案 0 :(得分:2)
您需要使用数组filter
-您有array(map)
,并且想拥有array(map)
。为此,您需要为filter
(一个lambda)构造过滤器功能。
(让我知道是否需要更详细的说明。)