'Windows version fails where jqplay.org works

I've been using jq to parse the output from AWS cli.

The output looks something like this..

{
"Vpcs": [
    {
        "CidrBlock": "10.29.19.64/26",
        "State": "available",
        "VpcId": "vpc-0ba51bd29c41d41",
        "IsDefault": false,
        "Tags": [
            {
                "Key": "Name",
                "Value": "CloudEndure-Europe-Development"
            }
        ]
    }
]}

and the script I am using looks like this..

.Vpcs[] | [.VpcId, .CidrBlock,   (.Tags[]|select(.Key=="Name")|.Value)]

If I run it under Windows it fails like this.

jq: error: Name/0 is not defined at , line 1: .Vpcs[] | [.VpcId, .CidrBlock, (.Tags[]|select(.Key==Name)|.Value)] jq: 1 compile error

But it works fine in jqplay.org.

Any ideas, on Windows Im using jq-1.6.

Thanks

Bruce.



Solution 1:[1]

I'm not agreeing to ikegami about the CMD command that [he/she?] provided because the character used for CMD escaping is ^, not \ like Assembly/C/C++. I hope this will work (I don't want to test this on my potato thing):

jq .Vpcs[] | [.VpcId, .CidrBlock, ( .Tags[] | select( .Key == "Name" ) | .Value ) ] file.json

or this:

jq .Vpcs[] | [.VpcId, .CidrBlock, ( .Tags[] | select( .Key == ^"Name^" ) | .Value ) ] file.json

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Honcky