Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not certain how to ask this --- filtering/json/other #25

Open
candrews67 opened this issue Oct 9, 2024 · 4 comments
Open

Not certain how to ask this --- filtering/json/other #25

candrews67 opened this issue Oct 9, 2024 · 4 comments

Comments

@candrews67
Copy link

If I execute this command meraki -j organizations getOrganizations I get the output , in json, that contains for example:
"api": {
"enabled": true
},

What would be the correct syntax to run the command where I could get id,name and "api"?
This will give me id and name: meraki -s id,name organizations getOrganizations but adding api to the '-s' does not work. I tried debugging but I was unable to use that information to figure out what I am wanting.

First, is what I want to do possible?

If so, what am I doing wrong when attempting to get arrays/dictionaries of sub elements or am I even using the correct terms?

THANKS!!

@PackeTsar
Copy link
Owner

PackeTsar commented Oct 10, 2024

If you turn up the debugging by running meraki -ddd -s id,name organizations getOrganizations, you will see why api doesn't appear in the tabulated data. It doesn't appear because it get squashed out of the data to be tabulated.

This squash happens because tabulation can only really be done against simple data structures which is where the value in each object's key,value pairs is something simple like a string or an integer. In the case of the api key, the value is complex (since it's another object).

There is currently no way in Meraki-CLI to coerce an object value to be tabulated. But that is something worth considering adding as a feature if it's something generally useful.

@candrews67
Copy link
Author

candrews67 commented Oct 10, 2024 via email

@PackeTsar
Copy link
Owner

The documentation also talks about it here in the "Incomplete Columns" box.

What it means is that Meraki-CLI can only turn simple data into a table. For example, this list of objects with simple values:

[
    {
        "id": "1234",
        "name": "Some Org 1",
    },
    {
        "id": "5678",
        "name": "Some Org 2",
    }
]

can be easily tabulated like this:

id name
1234 Some Org 1
5678 Some Org 2

but if those any of the values in the objects are complex (ie: not a simple data type):

[
    {
        "id": "1234",
        "name": "Some Org 1",
        "api": {
            "enabled": true
        }
    },
    {
        "id": "5678",
        "name": "Some Org 2",
        "api": {
            "enabled": true
        }
    }
]

then they can't be accurately tabulated.

@candrews67
Copy link
Author

candrews67 commented Oct 10, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants