If I call SwitchAudioSource -a -f json, I get separate lines of JSON for each device. However the output as a whole isn't valid JSON, so I can't just decode it in my language—I have to process each line separately. Perhaps it would be better if SwitchAudioSource output the results as an array instead. Of course, this would be a breaking change, but I'd say that ‘json output’ suggests that it can be just decoded all at once, so the fix is justified.
For that, it should be enough to wrap the output in [ and ], and to separate the lines with commas. But I'm not any good at C, so would probably find ways to mess this up.
One thing to look out for is, the JSON spec doesn't allow a comma after the last element of an array (or an object).
If I call
SwitchAudioSource -a -f json
, I get separate lines of JSON for each device. However the output as a whole isn't valid JSON, so I can't just decode it in my language—I have to process each line separately. Perhaps it would be better if SwitchAudioSource output the results as an array instead. Of course, this would be a breaking change, but I'd say that ‘json output’ suggests that it can be just decoded all at once, so the fix is justified.For that, it should be enough to wrap the output in
[
and]
, and to separate the lines with commas. But I'm not any good at C, so would probably find ways to mess this up.One thing to look out for is, the JSON spec doesn't allow a comma after the last element of an array (or an object).