Trouble with intersect and json data

#1

Hey folks, I saw some trouble comparing json data with intersect mentioned in the past, but that seems like is was resolved way back in v ~0.25. Not sure what I’m running into here:

I add some custom metadata to categories with a json file that sits alongside my content. This has worked great up until I’ve wanted to do some more complex filtering on these categories.

Here’s an example of my json list:

  {
    "name": "PermissionScope",
    "description": "Intelligent iOS permissions UI, <a href='http://github.com/nickoneill/PermissionScope'>open source</a>",
    "catName": "permissionscope",
    "color": "#fc6420",
    "archived": true
  },
  {
    "name": "Ideas",
    "description": "Before projects are projects they're just ideas.",
    "catName": "ideas",
    "color": "#148da6",
    "archived": true,
    "hide": true
  },

In this case, I have a long list of “archived” categories, some of which I want to show on the sidebar, most most I want to mark “hidden” and not show. I’m trying to achieve this by intersecting two where clauses like below:

{{ $archived := where $projects "archived" "ne" nil }}
{{ $notHidden := where $projects "hide" "eq" nil }}
{{ $shownArchived := intersect $archived $notHidden }}
{{ range $shownArchived }}

I have confirmed that both $archived and $notHidden have some of the same items in them, so they should intersect, but I always get 0 items from the intersect function.

Any ideas what I’m doing wrong?

#2

It’s difficult to say what’s wrong, without seeing more code and context. If you have your project in a repo you can share that we can test, that makes it easier for us to help. Please see Requesting Help.