Skip to content

Combining filterOr and mapOf #305

Answered by TomWright
eroth asked this question in Q&A
Discussion options

You must be logged in to vote

I think this does what you expect:

$ cat test.json | dasel -r json 'all().reactions.all().filterOr(equal(name,car),equal(name,pigeon)).mapOf(text,parent(2).text,reactions,.).merge()'

[
  {
    "reactions": {
      "count": 3,
      "name": "pigeon",
      "users": [
        "U01NMAR4LLE",
        "U04KXRR5H6Z",
        "U03DP251D9R"
      ]
    },
    "text": "Some great text"
  },
  {
    "reactions": {
      "count": 3,
      "name": "car",
      "users": [
        "U01NMAW4LLE",
        "U04KXRD5H6Z",
        "U03DP211D9R"
      ]
    },
    "text": "Some great text"
  }
]

You just needed parent(2) instead of parent(1).

parent(1) took the scope from here:

{
                "name": "p…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@eroth
Comment options

@TomWright
Comment options

@TomWright
Comment options

@TomWright
Comment options

Answer selected by eroth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants