4 ms·
I sometimes wish there was a linux command that when piped into turned anything into json readable format, so `ps | json-pipe` would output something like [{pid
by Crazyontap 5y ago
I sometimes wish there was a linux command that when piped into turned anything into json readable format, so `ps | json-pipe` would output something like [{pid: 133, name, etc}, ...] or `ls | json-pipe` would turn into [{name, size, etc}].
It would handle most known commands and maybe had plugin support for the rest.
Just a thought I had. Don't really know if it's possible or feasible. But it would make working with command line much more predictable and easier especially if it also supported jmespath! What do you guys think?
- daniellarusso 5y agoI saw this mentioned a few weeks ago: https://stedolan.github.io/jq https://stedolan.github.io/jq “Like sed for JSON data”
- drjasonharrison 5y agojq is a great tool for working with json data, but the author asked for a "command output in table format to json converter." The output would then be appropriate for jq.
- bronson 5y agoNushell comprehensively addresses this: https://www.nushell.sh https://www.nushell.sh (I don't have an opinion yet. Been meaning to try it for a year now but a shell is a difficult thing to switch)
- zaat 5y agoNot a linux command, but PowerShell (on linux) have a ConvertTo-Json cmdlet, it can parse dotnet object, so 'Get-ChildItem | ConvertTo-Json' will give you the output you want, but it is less successful with text so 'ls -alh | ConvertTo-Json' will give you an array and not distinct objects.
- cryptofistMonk 5y agoFor this to work on the command line, the json-pipe command would need some heuristic for parsing arbitrary input, could be tricky. Interestingly enough, the Arista CLI actually implements something like this, but it's not a real pipe or a separate command - each command implements it's own `<command> | json` handler.