yajsv icon indicating copy to clipboard operation
yajsv copied to clipboard

Allow JSON input via stdin

Open LukasPrediger opened this issue 2 years ago • 2 comments

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.

LukasPrediger avatar Sep 30 '21 11:09 LukasPrediger

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.

neilpa avatar Oct 01 '21 04:10 neilpa

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

joshqou avatar Feb 05 '22 20:02 joshqou