I have some json that looks like this
{
\"users\":[ {
\"id\":8734,
\"last_login\":\"2016-10-04T06:59:40Z\"
},
{
\"id\":9376,
\"l
Just add the appropriate null checks.
.users[] | select (.last_login | . == null or fromdateiso8601 > 1475625600).id
One way to protect against null values of .last_login would be as follows:
.users[]
| select ( .last_login // empty | fromdateiso8601 > 1475625600)
| .id
For clarity, though, I'd add parentheses, e.g.:
.users[]
| select ( (.last_login // empty) | fromdateiso8601 > 1475625600)
| .id
Or more defensively still, use ?
:
.users[]
| select ( .last_login | fromdateiso8601? > 1475625600)
| .id
If you want to include items for which .last_login evaluates to null
, then you could use the filter that Jeff suggested, or perhaps:
(.last_login | fromdateiso8601? > 1475625600) // true
P.S. For "90 days before now, expressed in seconds since the beginning of the Unix epoch", you could use:
def daysAgo(days): (now | floor) - (days * 86400);