5

I want to use jq for processing my json file in terminal. I am trying this command:

cat json.txt | jq 'name'

it's showing me

-bash: /usr/bin/jq: cannot execute binary file

Expected result:

Google

where json.txt is indeed a valid json file. I tried to check whether jq is installed correctly. Here's what I am getting:

 brew install jq

it's showing me:

Warning: jq-1.3 already installed

I am using mac. Anybody has any idea? The json.txt file is:

 {
    "name": "Google",
    "location":
            {
                    "street": "1600 Amphitheatre Parkway",
                    "city": "Mountain View",
                    "state": "California",
                    "country": "US"
            },
    "employees":
            [
                    {
                            "name": "Michael",
                            "division": "Engineering"
                    },
                    {
                            "name": "Laura",
                            "division": "HR"
                    },
                    {
                            "name": "Elise",
                            "division": "Marketing"
                    }
            ]
}

1 Answer 1

3

Regarding getting your expected result, the filter you want to use is:

.name

Note the .. You want to get the value of the name property.

As for the error, I don't know what your environment is but it seems to indicate that you've installed the wrong version of jq that isn't compatible with your OS. Look for a good tutorial on how to get it installed on your machine.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.