What is a good command line output format when used for further processing?
I've written a console application in Delphi that requests information from multiple locations. This application will be started by another process and the output to STDOUT will be captured by the startup process.
The information I receive must be interpreted by the calling application for reporting purposes. What is the best way to output this data to STDOUT so that it can be easily parsed? JSON? XML? CSV? The data, in particular, is information about the remote workstation, so it will pull in everything like running processes and details about each process.
Does anyone have any experience with this or suggestions?
a source to share
If you need something that can be easily analyzed, especially if it needs to be done quickly, go for the simplest format that can effectively convey the information you need. CSV, if you can try JSON. Definitely not XML if you really really need all the extra complexity for some reason.
a source to share
I would choose the Tab -delimited file if your data (as it seems) does not contain this character, as it allows for the fastest and easiest processing. All other formats are slower and more complex (even if they give you more energy).
The closest match is CSV, but CSV must indicate an element if the element contains some special characters defined by CSV (space, comma, quotes, etc.).
Because of the above, the tab-delimited format is the most compact, hence the fastest over the wire. (Since you are talking about remote workstations, I am assuming you are on some kind of network).
Also, it's worth mentioning that the tab-delimited format is highly readable, which makes debugging a lot easier if needed.
As an aside, if there is a tab character in your data stream, you can choose a different character that you are sure it cannot be. (For example, # 1, etc.). Of course, if the use case allows it.
NTN
a source to share
XML output format has the advantage that you can plug it into XSL format so that the XML data can be converted into a usable HTML document. (You can almost have cake and eat it too ) ...
a source to share