Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fgeller/jsonify
cli app to create JSON objects
https://github.com/fgeller/jsonify
cli go golang json
Last synced: 2 months ago
JSON representation
cli app to create JSON objects
- Host: GitHub
- URL: https://github.com/fgeller/jsonify
- Owner: fgeller
- Created: 2016-03-14T10:22:23.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-03-03T06:54:28.000Z (almost 3 years ago)
- Last Synced: 2024-08-02T15:47:53.948Z (5 months ago)
- Topics: cli, go, golang, json
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 26
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# jsonify
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## Installation
* Downloads are available from the [Releases](https://github.com/fgeller/jsonify/releases) section.
* `go get github.com/fgeller/jsonify && go install github.com/fgeller/jsonify`
* Via homebrew on OSX: `brew tap fgeller/tap && brew install jsonify`## Usage
jsonify [[-|=]name value]...
Converts arguments into JSON output.
## Details
* `-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.## Examples
$ # basic value types, ie - vs =
$ jsonify -name hans =age 23 =subscribed true =address null | jq
{
"address": null,
"age": 23,
"name": "hans",
"subscribed": true
}$ # nested objects via command substitution
$ jsonify =a `jsonify -name hans` =b `jsonify -name peter` | tee outfile | jq
{
"a": {
"name": "hans"
},
"b": {
"name": "peter"
}
}$ # subshell output as a value to get current date
$ # reading contents of "outfile" from previous invocation
$ jsonify -date "$(date)" =content outfile | jq
{
"content": {
"a": {
"name": "hans"
},
"b": {
"name": "peter"
}
},
"date": "Thu Mar 17 19:10:04 NZDT 2016"
}