diff --git a/README.md b/README.md index ae868a5..ccf616d 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,21 @@ The following options (each with default status) are supported to report: Proper validation of schemas requires additional libraries [ajv] and [ajv-formats] to be installed. +The JSON format emitted with option `-p` or `--print` looks like this: + +~~~json +{ + "fields": [ + { "key": "tag1", "value": "..." }, + { "key": "tag2", "value": "..." } + ], + "types": [] +} +~~~ + +It can be converted to flat key-value structure by piping to +[jq](https://jqlang.github.io/jq/) command `jq '.fields|from_entries'`. + ## API ### Validator diff --git a/lib/action.js b/lib/action.js index 7d3980e..634abf7 100644 --- a/lib/action.js +++ b/lib/action.js @@ -121,6 +121,7 @@ export async function validateFiles(files, schema, validationOptions, opt) { ok = false }) if (print) { + record.fields = record.fields.map(({tag,value}) => ({key:tag,value})) console.log(JSON.stringify(record)) } })