Forum Discussion

Hannes_Rapp's avatar
Hannes_Rapp
Icon for Nimbostratus rankNimbostratus
May 13, 2015

iControlRest - How to limit the output to a single parameter?

Hi,

I'm aware that you can pass ?$select= to limit the iControlRest output to a single parameter. It does reduce the output significantly, but its still a bit too much.

Question - how can I further reduce the output (using iControl) to have only the following output:

"fullPath":"/Common/mysecurity-policy_443"

Instead of

[root@bigip1:Active:Changes Pending] ~  curl -sk -u admin:admin https://localhost/mgmt/tm/asm/policies/V9NGrsJI4rJFeyE6uYG7yw/?\$select=fullPath
{"selfLink":"https://localhost/mgmt/tm/asm/policies/V9NGrsJI4rJFeyE6uYG7yw$select=fullPath","kind":"tm:asm:policies:policystate","fullPath":"/Common/mysecurity-policy_443"}
[root@bigip1:Active:Changes Pending] ~ 

1 Reply

  • Check out the jq command line JSON processor. You can run your curl command and use jq to parse and select elements. More details here: http://stedolan.github.com/jq

    $ curl -sk -u admin:admin https://localhost/mgmt/tm/asm/policies/V9NGrsJI4rJFeyE6uYG7yw/?\$select=fullPath | jq "{fullPath: .fullPath}"` 
    

    Will return

    {
      "fullPath": "/Common/mysecurity-policy_443"
    }
    

    It doesn't change the amount of data downloaded but should help with client-side parsing.

    -Joe