yajsv
yajsv copied to clipboard
Allow JSON input via stdin
Allowing the json to be comming in from stdin would allow piped operations like consuming a kafka topic and validating all messages.
When no json file is specified, the program should read the standard input.
Sounds reasonable to me. Probably also want to treat -
as a positional argument to explicitly read from stdin
.
The only thing I wonder about is YAML support in this mode. Right now yajsv
relies on looking at the file extension to determine format. Maybe it's ok to just support JSON as a stdin
reader though.
Might be better to do a magic check against the first byte of the input, i.e: Assuming JSON input if the starting byte is {
, [
, or "
. You could also add an --input-format
flag or something so the format can be declared