Some reasons why you might be interested:
- Quickly produce JSON output based on command line arguments
- Simple syntax to interpret values as strings or arbitrary JSON values
- Supports reading file contents for easy escaping
- Downloads are available from the Releases section.
go get github.com/fgeller/jsonify && go install github.com/fgeller/jsonify
jsonify [[-|=]name value]...
Converts arguments into JSON output.
-name
causes the value to be interpreted as a string.=name
causes the value to be interpreted as a JSON value.- If the value is a valid file path, it's contents are used as the value.
$ jsonify -first_name hans -last_name schmitt | jq
{
"first_name": "hans",
"last_name": "schmitt"
}
$ jsonify =a `+"`"+`jsonify -name hans`+"`"+` =b `+"`"+`jsonify -name peter`+"`"+` | tee out | jq
{
"a": {
"name": "hans"
},
"b": {
"name": "peter"
}
}
$ jsonify -date "$(date)" =content out | jq
{
"content": {
"a": {
"name": "hans"
},
"b": {
"name": "peter"
}
},
"date": "Thu Mar 17 19:10:04 NZDT 2016"
}