Skip to content

hints for handling complex JSON? #904

Answered by lmorg
JeffMelton asked this question in Q&A
Discussion options

You must be logged in to vote

Sounds like a few issues.

Casting

Generic is the default output from any POSIX pipe because it's hard to assume what an output will be for tools that just pass raw byte streams.

You can create a function to override that default, eg

function vminfo {
    cast json
    exec govc vm.info -json @PARAMS
}

so now your command line looks like:

vminfo node3 -> [virtualMachines] ...

I've been hesitant to do any automatic detection of data types based on their stdout/stdin because it is error prone. But if you know of a way it can be implemented in a reliable and deterministic way, then it's definitely something I can consider.

Element vs Index

Index [ ... ] is useful because it's case insensiti…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@JeffMelton
Comment options

@lmorg
Comment options

@JeffMelton
Comment options

@JeffMelton
Comment options

@lmorg
Comment options

Answer selected by JeffMelton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants