4 ms·
I wonder if a tool could parse any terminal output into json in a really dumb and deterministic way: { "lines": [ "line1 bla bla",
by mejutoco 3y ago
I wonder if a tool could parse any terminal output into json in a really dumb and deterministic way:
{
"lines": [
"line1 bla bla",
"line1 bla bla",
],
"words": [
"word1",
"word2",
],
}
With enough representations (maybe multiple of the same thing) to make it easy to process, without knowing sed or similar. It seems hacky but it would not require any maintenance for each command, and would only change if the actual output changes.
- hk__2 3y agoWhat’s the point of JSON, then?
- mejutoco 3y ago> without knowing sed or similar Not having to know sed or a similar tool. Most unix tools are structured in lines, columns, etc. anyway.
- hk__2 3y ago> Not having to know sed or a similar tool. But you get a JSON with a list of lines that you still have to process in some way. Instead of having a program that reads the input line by line, you read a JSON that contains a list of lines.
- mejutoco 3y agoYou could have multiple representations of it. For example split by tabs to represent columns in a cronfile, so you could choose lines to get the second lines or columns to get the 3rd column etc. Anyway, just brainstorming here.