Skip to content

Searching a specific attribute value in an array #369

Answered by catull
NB2909 asked this question in Q&A
Discussion options

You must be logged in to vote

Here's a solution.

Input

{
  "attribute1": "This is a test",
  "array": [
    { "test1234": "abc" },
    { "test1234": "cde" },
    { "test1234": "xyz" }
  ]
}

With this transformation:

{
  "attribute1": .attribute1,
  "attribute2": contains ("xyz", [ for (.array) .test1234 ])
}

The result is:

{
  "attribute1" : "This is a test",
  "attribute2" : true
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@NB2909
Comment options

Answer selected by NB2909
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