Christian Meißner
Christian Meißner

Reputation: 243

Select a dict from a list where one value does not matches another with jq

There is the following data structure (list of dicts):

[
    {
        "name": "foo",
        "value": "value1",
        "default": "value1"
    },
    {
        "name": "bar",
        "value": "blafasel",
        "default": "value2"
    }
]

We are now looking for a jq filter to get all dicts where value and default are not equal.

Upvotes: 0

Views: 2851

Answers (1)

choroba
choroba

Reputation: 241868

Iterate over the dicts by .[], select only those that have the value different to the default:

jq '.[] | select (.value != .default)' file.json

Upvotes: 2

Related Questions