go-jmespath icon indicating copy to clipboard operation
go-jmespath copied to clipboard

Filtering objects by date

Open rem7 opened this issue 2 years ago • 1 comments

How do you filter by time.Time? I was trying to filter Amazon S3 Objects from the list api and I can't get it to work in go, but I can get it to work in jmespath.org.

This seems to work in jmespath.org but not in go-jmespath [?LastModified>'2023-01-23T00:00:00Z' && LastModified<'2023-04-01T00:00:00Z']

Here is an example

[
  {
    "ChecksumAlgorithm": null,
    "ETag": "\"d41d8cd98f00b204e9800998ecf8427e\"",
    "Key": "images-demo/",
    "LastModified": "2023-03-23T21:07:02Z",
    "Owner": null,
    "Size": 0,
    "StorageClass": "STANDARD"
  },
  {
    "ChecksumAlgorithm": null,
    "ETag": "\"8fe2b567e7ded83cbf12c76104da11b4\"",
    "Key": "images-demo/1.jpg",
    "LastModified": "2023-03-23T21:07:21Z",
    "Owner": null,
    "Size": 5104348,
    "StorageClass": "STANDARD"
  },
  {
    "ChecksumAlgorithm": null,
    "ETag": "\"0fba471e21efe99aba7a9caf20cab050\"",
    "Key": "images-demo/7.jpg",
    "LastModified": "2023-04-19T22:26:08Z",
    "Owner": null,
    "Size": 207020,
    "StorageClass": "STANDARD"
  }
]

rem7 avatar Apr 20 '23 00:04 rem7

Comparison is officially only supported for numbers.

However, we are thinking about proposing type-conversion in an upcoming version of the spec.

springcomp avatar Jun 19 '23 21:06 springcomp